Skip to content

Support pylock.toml in --with-requirements in uv run and uvx#19127

Open
zanieb wants to merge 5 commits intomainfrom
claude/investigate-feature-support-5S51M
Open

Support pylock.toml in --with-requirements in uv run and uvx#19127
zanieb wants to merge 5 commits intomainfrom
claude/investigate-feature-support-5S51M

Conversation

@zanieb
Copy link
Copy Markdown
Member

@zanieb zanieb commented Apr 23, 2026

Closes #19117

They silently ignores the option when provided today.

@zanieb zanieb force-pushed the claude/investigate-feature-support-5S51M branch from b8b402e to 82e123f Compare April 23, 2026 15:36
Comment thread crates/uv/src/commands/project/run.rs
Comment thread crates/uv/src/commands/pylock.rs Outdated
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 23, 2026

Merging this PR will not alter performance

✅ 5 untouched benchmarks


Comparing claude/investigate-feature-support-5S51M (5e4df21) with main (d46a7b6)

Open in CodSpeed

claude and others added 5 commits April 23, 2026 14:43
`uv tool run` / `uvx` accepted `--with-requirements pylock.toml` (and the
spec layer classified the file as a `PylockToml` source) but the pylock
field was silently dropped when `CachedEnvironment::from_spec` destructured
the `RequirementsSpecification`, so the locked packages never made it into
the tool environment. Mirror `pip install`'s behavior by deriving the
`Resolution` from the pylock directly when present, bypassing the
resolver; this also benefits `uv run --with-requirements pylock.toml`.

Closes #19117.
The prior commit wired `pylock.toml` through `CachedEnvironment::from_spec`,
but `uv run` has an additional gate: `can_skip_ephemeral` inspects only
`spec.requirements`, which is empty when a `pylock.toml` is the sole
source. That caused `uv run` to bypass `CachedEnvironment::from_spec`
entirely and silently skip installing the pylock's packages. Opt out of
the skip when `spec.pylock` is set, and cover the path with an
integration test.
Extract the previously-duplicated `pylock.toml` reading, Python-compat
check, and `to_resolution` logic from `pip install` and `pip sync` into
`commands::pylock` (`read_pylock_toml` + `resolve_pylock_toml`), and
reuse it from `CachedEnvironment::from_spec` so that
`uvx --with-requirements pylock.toml` and `uv run --with-requirements
pylock.toml` now also hash-verify downloads against the pylock, matching
`pip install` / `pip sync` behavior. Thread the pylock-derived
`HashStrategy` through a new optional `hasher` parameter on
`sync_environment`. `pip sync` also gains HTTP(S) `pylock.toml` support
as a natural consequence of sharing the reader with `pip install`.
Extract the previously-duplicated `pylock.toml` reading, Python-compat
check, and `to_resolution` logic from `pip install` and `pip sync` into
`commands::pylock` (`read_pylock_toml` + `resolve_pylock_toml`), and
reuse it from `CachedEnvironment::from_spec` so that
`uvx --with-requirements pylock.toml` and `uv run --with-requirements
pylock.toml` now also hash-verify downloads against the pylock, matching
`pip install` / `pip sync` behavior. Thread the pylock-derived
`HashStrategy` through a new optional `hasher` parameter on
`sync_environment`. `pip sync` also gains HTTP(S) `pylock.toml` support
as a natural consequence of sharing the reader with `pip install`.
@zanieb zanieb force-pushed the claude/investigate-feature-support-5S51M branch from 34a0037 to 5e4df21 Compare April 23, 2026 18:44
@zanieb zanieb marked this pull request as ready for review April 23, 2026 20:57
@zanieb zanieb requested a review from charliermarsh April 23, 2026 20:57
@zanieb
Copy link
Copy Markdown
Member Author

zanieb commented Apr 23, 2026

This might be intentionally unsupported, as it doesn't merge with the tool resolution. It's just layered on top.

We might need constraint support for this to work as users expect? ref #13031

@zanieb zanieb added the needs-decision Undecided if this should be done label Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-decision Undecided if this should be done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uvx with a pylock.toml (E.g. --with-pylock or reuse --with-requirements)

2 participants