-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use environment layering for uv run --with
#3447
Conversation
bbf05da
to
db8c09d
Compare
// Sync the workspace requirements. | ||
Some(sync_environment(venv, &workspace_requirements, preview, cache, printer).await?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just throwing this out here to think about... wouldn't it be annoying if we exposed a default environment at .venv
and every time you used uv run
any manual changes you had made were undone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, though this doesn't uninstall anything, it just makes sure it's in-sync with the (in-the-future) lockfile. Does that seem right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah we'll need to be careful with "in sync" because sync implies an exact match (no extra packages) to me. Seems ideal not to remove packages unless requested? Like.. uv sync --strict
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in uv run, not uv sync. For now, neither one is removing packages, but I don’t feel strongly about the behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that, I'm talking more generally.
uv run
should not probably not remove extraneous packages (and I understand that is the current behavior).
0930363
to
2b1e115
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know how resource discovery interacts with PYTHONPATH
, e.g. for finding jupyter kernels?
iter::once(python_env.scripts().to_path_buf()).chain(env::split_paths(&path)); | ||
env::join_paths(python_env_path)? | ||
// If necessary, create an environment for the ephemeral requirements. | ||
let tmpdir; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's curious, how is that implemented in rust, does this insert a conditional drop?
5da8977
to
f8e9aa7
Compare
f236a64
to
9085bba
Compare
9085bba
to
fcb6720
Compare
Summary
This PR takes a different approach to
--with
foruv run
. Now, instead of merging the requirements and re-resolving, we have two phases: (1) sync the workspace requirements to the workspace environment; then (2) sync the ephemeral--with
requirements to an ephemeral environment. The two environments are then layered by setting thePATH
andPYTHONPATH
variables appropriately.I think this approach simplifies a few things:
--with
, then it's not really clear how the lockfile would/should behave.The current version of this PR loses a few behaviors though that I need to restore:
--python
support -- but I'm not yet sure how this is supposed to behave within projects? It's also left unclear inuv sync
anduv lock
.Closes #3411.