Skip to content

Add packaging functions to Tower SDK#199

Merged
bradhe merged 17 commits intodevelopfrom
tasks/add-packaging-to-tower-sdk
Feb 11, 2026
Merged

Add packaging functions to Tower SDK#199
bradhe merged 17 commits intodevelopfrom
tasks/add-packaging-to-tower-sdk

Conversation

@bradhe
Copy link
Contributor

@bradhe bradhe commented Feb 10, 2026

This PR is our first bit of functionality exposing rust code to the Python SDK. It adds a new function build_package that creates a package that can be used for deployments to Tower.

Summary by CodeRabbit

Release Notes

  • New Features

    • Tower is now available as a native Python package with a build_package() function for programmatic use.
    • Tower CLI is now directly callable from Python.
  • Tests

    • Added comprehensive test coverage for package building functionality.
  • Chores

    • Improved build system to support multiple Python versions.

@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tasks/add-packaging-to-tower-sdk

Comment @coderabbitai help to get the list of available commands and usage tips.

with:
target: x86_64
args: --release --locked --out dist
args: --release --locked --out dist -i python3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What changed and we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had many interpreters available in the OS, we had to tell it specifically which one to use. It's complicated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I..... trust you


// Everything must happen inside block_on because Package holds a TmpDir
// whose Drop implementation requires an active tokio reactor.
rt.block_on(async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rt was not very descriptive here and I had to look for the declaration.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.github/workflows/build-binaries.yml:
- Line 109: Add the pip flag --no-index to every CI install invocation that
currently uses --find-links so pip won’t fallback to PyPI; update the
occurrences of "pip install ${{ env.PACKAGE_NAME }} --find-links dist/
--force-reinstall", the "python -m pip install" call, the standalone "pip
install" and "pip3 install" invocations, and the ".venv/bin/pip3 install"
commands to include --no-index (place it alongside --find-links/other flags) so
the tests only use the local dist artifacts.
- Around line 126-129: The workflow uses an invalid Maturin interpreter flag
value "interpreter: -i 3.13"; change that entry to provide an executable name
(e.g., "interpreter: -i python3" or "interpreter: -i python3.13") so the ARM
aarch64 build uses a valid --interpreter value; update the "interpreter: -i
3.13" line to match the other builds' "interpreter: -i python3" (or a specific
python executable) to avoid Maturin failing.
🧹 Nitpick comments (2)
src/tower/__init__.py (1)

28-29: Consider deferring native import failure for better UX.

A guarded import would keep the package importable and surface a clearer error only when build_package is actually called.

♻️ Suggested change
-from ._native import build_package
+try:
+    from ._native import build_package
+except Exception as exc:
+    def build_package(*args, **kwargs):
+        raise RuntimeError(
+            "tower._native extension is not available. Reinstall with a compatible wheel "
+            "or build from source with Rust."
+        ) from exc
tests/tower/test_build_package.py (1)

28-36: Close extracted file handles in _read_package.

tar.extractfile() returns a file-like object (io.BufferedReader) that should be closed to prevent file descriptor leaks when reading many entries.

♻️ Suggested change
-            if member.isfile():
-                f = tar.extractfile(member)
-                entries[member.name] = f.read().decode("utf-8") if f else ""
+            if member.isfile():
+                f = tar.extractfile(member)
+                if f:
+                    with f:
+                        entries[member.name] = f.read().decode("utf-8")
+                else:
+                    entries[member.name] = ""

@bradhe bradhe force-pushed the tasks/add-packaging-to-tower-sdk branch from 7f25bc6 to bfe5e5c Compare February 11, 2026 15:21
@bradhe bradhe merged commit 96b07fc into develop Feb 11, 2026
17 checks passed
@bradhe bradhe deleted the tasks/add-packaging-to-tower-sdk branch February 11, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants