Skip to content

v0.3.61 release#271

Merged
bradhe merged 3 commits intomainfrom
develop
Apr 28, 2026
Merged

v0.3.61 release#271
bradhe merged 3 commits intomainfrom
develop

Conversation

@bradhe
Copy link
Copy Markdown
Contributor

@bradhe bradhe commented Apr 27, 2026

  • Only require setuptools when an initial attempt to setup the environment fails

Summary by CodeRabbit

  • Release

    • Bumped package version to v0.3.61.
  • Chores

    • Updated workspace/dev dependencies (added a dev-only utility crate).
  • Bug Fixes

    • Improved dependency-installation reliability with an automatic retry/fallback for setuptools compatibility during sync.
  • Tests

    • Added integration tests covering dependency sync, fallback behavior, and error conditions.

* Only require setuptools when an initial probe fails

* All dependencies come from workspace

* Make commentary a little less specific

* Fall back to doing a pinned version install only if the first one fails
@bradhe bradhe requested review from sammuti and socksy April 27, 2026 15:48
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c4f7cb17-b5ae-4f86-839d-982f0c79ef16

📥 Commits

Reviewing files that changed from the base of the PR and between a5a9423 and 4f12c5e.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • Cargo.toml
  • pyproject.toml
✅ Files skipped from review due to trivial changes (2)
  • pyproject.toml
  • Cargo.toml

📝 Walkthrough

Walkthrough

Adds a retry path for dependency installation: uv.sync can now be retried with a legacy setuptools<82 pin; new Uv helpers and a spawn helper were added, integration tests introduced, and workspace/package versions and a dev dependency were bumped.

Changes

Cohort / File(s) Summary
Workspace & Python metadata
Cargo.toml, pyproject.toml
Bumped workspace/package version from 0.3.600.3.61.
Dev dependency
crates/tower-uv/Cargo.toml
Added tempfile under [dev-dependencies].
Runtime retry orchestration
crates/tower-runtime/src/local.rs
On uv.sync failure, capture exit code, query legacy-setuptools decision, and conditionally retry via sync_with_legacy_setuptools_pin; connects stdout/stderr drains and propagates final exit/status.
Uv sync refactor & API
crates/tower-uv/src/lib.rs
Added spawn_requirements_install helper, should_use_legacy_setuptools_pin(&self, cwd: &Path) -> bool, and sync_with_legacy_setuptools_pin(&self, cwd: &PathBuf, env_vars: &HashMap<..., ...>) -> Result<Child, Error>; refactored sync flow to support optional setuptools<82 retry.
Integration tests
crates/tower-uv/tests/sync_test.rs
New Tokio tests covering plain sync, modern setuptools, legacy fallback success/failure, and missing requirements.txt error scenarios.

Sequence Diagram

sequenceDiagram
    participant LocalExec as Local Executor
    participant Uv as Uv Service
    participant Child as Child Process

    LocalExec->>Uv: sync(cwd, env_vars)
    Uv->>Child: spawn_requirements_install(...) (plain)
    Child-->>Uv: exit_code (res)
    alt res == 0
        Uv-->>LocalExec: return success (child)
    else res != 0
        Uv->>Uv: should_use_legacy_setuptools_pin(cwd)?
        alt true
            LocalExec->>Uv: sync_with_legacy_setuptools_pin(cwd, env_vars)
            Uv->>Child: spawn_requirements_install(...) (with setuptools<82)
            Child-->>Uv: retry_exit_code (res)
            Uv-->>LocalExec: return retry result
        else false
            Uv-->>LocalExec: return original error/result
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • socksy
  • jo-sm
  • giray123
  • sammuti

🐰
I hop through builds with nimble feet,
I try once more when installs don't meet.
A legacy pin, a gentle retry,
Tests nod, versions rise — hop, we fly! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'v0.3.61 release' directly corresponds to the version bumps in Cargo.toml and pyproject.toml, and the PR's primary purpose is a release with the setuptools fallback feature as the main functional change.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch develop

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

Copy link
Copy Markdown

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/tower-runtime/src/local.rs`:
- Around line 278-320: The code retries with sync_with_legacy_setuptools_pin
even when the initial wait_for_process returned due to cancellation; update the
if guard to skip the fallback if cancellation already happened by checking the
cancel token (e.g. require !cancel_token.is_cancelled() or equivalent) before
calling uv.should_use_legacy_setuptools_pin and spawning the retry; modify the
block around wait_for_process / res so that retry logic
(uv.sync_with_legacy_setuptools_pin, spawning retry_child drains and
wait_for_process on retry_child) only runs when not cancelled to prevent
terminate() restarts.

In `@crates/tower-uv/src/lib.rs`:
- Around line 367-373: The helper should_use_legacy_setuptools_pin currently
returns true if requirements.txt exists even when pyproject.toml is present;
change it to match sync()'s strategy selection by returning true only when
requirements.txt exists and pyproject.toml does not (i.e., check both
cwd.join("requirements.txt").exists() and !cwd.join("pyproject.toml").exists()).
Update the function body for should_use_legacy_setuptools_pin to reflect that
logic so a pyproject-driven project won't fall back to the legacy requirements
path.

In `@crates/tower-uv/tests/sync_test.rs`:
- Around line 19-21: The helper async fn wait(mut child: Child) -> i32 can
deadlock because child's stdout/stderr are piped and not consumed; before
calling child.wait().await you must drain both streams to EOF (use
child.stdout.take() and child.stderr.take() and spawn async readers or await
tokio::io::copy / read_to_end into a sink) so the pipes cannot fill and block
the child; after both drains complete, call child.wait().await and return the
exit code as before.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a3269712-45ae-4cce-bf08-bb2545f7f138

📥 Commits

Reviewing files that changed from the base of the PR and between e11b5cc and 16eb47f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • Cargo.toml
  • crates/tower-runtime/src/local.rs
  • crates/tower-uv/Cargo.toml
  • crates/tower-uv/src/lib.rs
  • crates/tower-uv/tests/sync_test.rs

Comment on lines +278 to +320
let mut res = wait_for_process(ctx.clone(), &cancel_token, child).await;

// If the requirements.txt install failed, retry with the legacy
// setuptools<82 pin. Some apps (those whose transitive deps rely on
// pkg_resources) need that pin to install successfully; we don't
// apply it by default because it conflicts with apps whose deps
// require setuptools>=82.
if res != 0 && uv.should_use_legacy_setuptools_pin(&working_dir) {
let _ = opts.output_sender.send(Output {
channel: Channel::Setup,
fd: FD::Stdout,
line: "tower: dependency install failed; retrying with setuptools<82 pin for pkg_resources compatibility".to_string(),
time: chrono::Utc::now(),
});

match uv
.sync_with_legacy_setuptools_pin(&working_dir, &env_vars)
.await
{
Err(e) => {
return Err(e.into());
}
Ok(mut retry_child) => {
let stdout = retry_child.stdout.take().expect("no stdout");
tokio::spawn(drain_output(
FD::Stdout,
Channel::Setup,
opts.output_sender.clone(),
BufReader::new(stdout),
));

let stderr = retry_child.stderr.take().expect("no stderr");
tokio::spawn(drain_output(
FD::Stderr,
Channel::Setup,
opts.output_sender.clone(),
BufReader::new(stderr),
));

res = wait_for_process(ctx.clone(), &cancel_token, retry_child).await;
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Skip the fallback when cancellation already happened.

If the first sync exits with -1 because cancel_token fired, Line 285 still retries and spawns a second install. That makes terminate() restart work instead of stopping it.

Suggested fix
-                if res != 0 && uv.should_use_legacy_setuptools_pin(&working_dir) {
+                if res != 0
+                    && !cancel_token.is_cancelled()
+                    && uv.should_use_legacy_setuptools_pin(&working_dir)
+                {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let mut res = wait_for_process(ctx.clone(), &cancel_token, child).await;
// If the requirements.txt install failed, retry with the legacy
// setuptools<82 pin. Some apps (those whose transitive deps rely on
// pkg_resources) need that pin to install successfully; we don't
// apply it by default because it conflicts with apps whose deps
// require setuptools>=82.
if res != 0 && uv.should_use_legacy_setuptools_pin(&working_dir) {
let _ = opts.output_sender.send(Output {
channel: Channel::Setup,
fd: FD::Stdout,
line: "tower: dependency install failed; retrying with setuptools<82 pin for pkg_resources compatibility".to_string(),
time: chrono::Utc::now(),
});
match uv
.sync_with_legacy_setuptools_pin(&working_dir, &env_vars)
.await
{
Err(e) => {
return Err(e.into());
}
Ok(mut retry_child) => {
let stdout = retry_child.stdout.take().expect("no stdout");
tokio::spawn(drain_output(
FD::Stdout,
Channel::Setup,
opts.output_sender.clone(),
BufReader::new(stdout),
));
let stderr = retry_child.stderr.take().expect("no stderr");
tokio::spawn(drain_output(
FD::Stderr,
Channel::Setup,
opts.output_sender.clone(),
BufReader::new(stderr),
));
res = wait_for_process(ctx.clone(), &cancel_token, retry_child).await;
}
}
}
let mut res = wait_for_process(ctx.clone(), &cancel_token, child).await;
// If the requirements.txt install failed, retry with the legacy
// setuptools<82 pin. Some apps (those whose transitive deps rely on
// pkg_resources) need that pin to install successfully; we don't
// apply it by default because it conflicts with apps whose deps
// require setuptools>=82.
if res != 0
&& !cancel_token.is_cancelled()
&& uv.should_use_legacy_setuptools_pin(&working_dir)
{
let _ = opts.output_sender.send(Output {
channel: Channel::Setup,
fd: FD::Stdout,
line: "tower: dependency install failed; retrying with setuptools<82 pin for pkg_resources compatibility".to_string(),
time: chrono::Utc::now(),
});
match uv
.sync_with_legacy_setuptools_pin(&working_dir, &env_vars)
.await
{
Err(e) => {
return Err(e.into());
}
Ok(mut retry_child) => {
let stdout = retry_child.stdout.take().expect("no stdout");
tokio::spawn(drain_output(
FD::Stdout,
Channel::Setup,
opts.output_sender.clone(),
BufReader::new(stdout),
));
let stderr = retry_child.stderr.take().expect("no stderr");
tokio::spawn(drain_output(
FD::Stderr,
Channel::Setup,
opts.output_sender.clone(),
BufReader::new(stderr),
));
res = wait_for_process(ctx.clone(), &cancel_token, retry_child).await;
}
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/tower-runtime/src/local.rs` around lines 278 - 320, The code retries
with sync_with_legacy_setuptools_pin even when the initial wait_for_process
returned due to cancellation; update the if guard to skip the fallback if
cancellation already happened by checking the cancel token (e.g. require
!cancel_token.is_cancelled() or equivalent) before calling
uv.should_use_legacy_setuptools_pin and spawning the retry; modify the block
around wait_for_process / res so that retry logic
(uv.sync_with_legacy_setuptools_pin, spawning retry_child drains and
wait_for_process on retry_child) only runs when not cancelled to prevent
terminate() restarts.

Comment on lines +367 to +373
/// Returns whether a failed `sync()` for this directory is eligible for a
/// retry via [`sync_with_legacy_setuptools_pin`]. Only applies to projects
/// driven by `requirements.txt`; pyproject-based projects manage their own
/// setuptools dependency.
pub fn should_use_legacy_setuptools_pin(&self, cwd: &Path) -> bool {
cwd.join("requirements.txt").exists()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Match the retry gate to sync()'s strategy selection.

sync() treats pyproject.toml as authoritative when both files exist, but this helper returns true for any directory with requirements.txt. That means a failed pyproject-based sync can fall back to the requirements path and install a different dependency set.

Suggested fix
     pub fn should_use_legacy_setuptools_pin(&self, cwd: &Path) -> bool {
-        cwd.join("requirements.txt").exists()
+        cwd.join("requirements.txt").exists() && !cwd.join("pyproject.toml").exists()
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Returns whether a failed `sync()` for this directory is eligible for a
/// retry via [`sync_with_legacy_setuptools_pin`]. Only applies to projects
/// driven by `requirements.txt`; pyproject-based projects manage their own
/// setuptools dependency.
pub fn should_use_legacy_setuptools_pin(&self, cwd: &Path) -> bool {
cwd.join("requirements.txt").exists()
}
/// Returns whether a failed `sync()` for this directory is eligible for a
/// retry via [`sync_with_legacy_setuptools_pin`]. Only applies to projects
/// driven by `requirements.txt`; pyproject-based projects manage their own
/// setuptools dependency.
pub fn should_use_legacy_setuptools_pin(&self, cwd: &Path) -> bool {
cwd.join("requirements.txt").exists() && !cwd.join("pyproject.toml").exists()
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/tower-uv/src/lib.rs` around lines 367 - 373, The helper
should_use_legacy_setuptools_pin currently returns true if requirements.txt
exists even when pyproject.toml is present; change it to match sync()'s strategy
selection by returning true only when requirements.txt exists and pyproject.toml
does not (i.e., check both cwd.join("requirements.txt").exists() and
!cwd.join("pyproject.toml").exists()). Update the function body for
should_use_legacy_setuptools_pin to reflect that logic so a pyproject-driven
project won't fall back to the legacy requirements path.

Comment on lines +19 to +21
async fn wait(mut child: Child) -> i32 {
let status = child.wait().await.expect("wait failed");
status.code().unwrap_or(-1)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

git ls-files | grep -E "sync_test|tests.*sync" | head -20

Repository: tower/tower-cli

Length of output: 94


🏁 Script executed:

find crates -name "sync_test.rs" -type f

Repository: tower/tower-cli

Length of output: 94


🏁 Script executed:

cat -n crates/tower-uv/tests/sync_test.rs

Repository: tower/tower-cli

Length of output: 5655


🏁 Script executed:

find crates/tower-uv -name "*.rs" -type f | grep -v test | head -10

Repository: tower/tower-cli

Length of output: 117


🏁 Script executed:

cat -n crates/tower-uv/src/lib.rs | head -150

Repository: tower/tower-cli

Length of output: 6863


🏁 Script executed:

rg -n "fn venv\|fn sync\|fn sync_with_legacy_setuptools_pin" crates/tower-uv/src/lib.rs

Repository: tower/tower-cli

Length of output: 41


🏁 Script executed:

wc -l crates/tower-uv/src/lib.rs

Repository: tower/tower-cli

Length of output: 90


🏁 Script executed:

grep -n "fn venv\|fn sync" crates/tower-uv/src/lib.rs | head -20

Repository: tower/tower-cli

Length of output: 167


🏁 Script executed:

sed -n '291,320p' crates/tower-uv/src/lib.rs

Repository: tower/tower-cli

Length of output: 779


🏁 Script executed:

sed -n '321,384p' crates/tower-uv/src/lib.rs

Repository: tower/tower-cli

Length of output: 2554


🏁 Script executed:

sed -n '385,430p' crates/tower-uv/src/lib.rs

Repository: tower/tower-cli

Length of output: 1309


🏁 Script executed:

sed -n '420,450p' crates/tower-uv/src/lib.rs

Repository: tower/tower-cli

Length of output: 716


Drain child output before waiting.

These tests call wait() on children whose stdout/stderr are piped by Uv, but never consume those streams. If uv writes enough output, the child can block on a full pipe and the test hangs.

Suggested fix
 async fn wait(mut child: Child) -> i32 {
-    let status = child.wait().await.expect("wait failed");
-    status.code().unwrap_or(-1)
+    let output = child.wait_with_output().await.expect("wait failed");
+    output.status.code().unwrap_or(-1)
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async fn wait(mut child: Child) -> i32 {
let status = child.wait().await.expect("wait failed");
status.code().unwrap_or(-1)
async fn wait(mut child: Child) -> i32 {
let output = child.wait_with_output().await.expect("wait failed");
output.status.code().unwrap_or(-1)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/tower-uv/tests/sync_test.rs` around lines 19 - 21, The helper async fn
wait(mut child: Child) -> i32 can deadlock because child's stdout/stderr are
piped and not consumed; before calling child.wait().await you must drain both
streams to EOF (use child.stdout.take() and child.stderr.take() and spawn async
readers or await tokio::io::copy / read_to_end into a sink) so the pipes cannot
fill and block the child; after both drains complete, call child.wait().await
and return the exit code as before.

@bradhe bradhe merged commit 18c175e into main Apr 28, 2026
32 checks passed
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