-
Notifications
You must be signed in to change notification settings - Fork 636
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
Add uv run --package
#3864
Add uv run --package
#3864
Conversation
CodSpeed Performance ReportMerging #3864 will improve performances by 6.72%Comparing Summary
Benchmarks breakdown
|
0630666
to
f5fd323
Compare
69ab0fc
to
eac4c00
Compare
Add a `--package` option that allows switching the current project in the workspace. Wherever you are in a workspace, you should be able to run with any other project as root. This is the uv equivalent of `cargo run -p`. I don't love the `--package` name, esp. since `-p` is already taken and in general to many things start with p already. ## Usage In albatross-virtual-workspace: ```console $ uv venv $ uv run --preview --package bird-feeder python -c "import albatross" Built file:///home/konsti/projects/uv/scripts/workspaces/albatross-virtual-workspace/packages/bird-feeder Built file:///home/konsti/projects/uv/scripts/workspaces/albatross-virtual-workspace/packages/seeds Built 2 editables in 167ms Resolved 5 packages in 4ms Installed 5 packages in 1ms + anyio==4.4.0 + bird-feeder==1.0.0 (from file:///home/konsti/projects/uv/scripts/workspaces/albatross-virtual-workspace/packages/bird-feeder) + idna==3.6 + seeds==1.0.0 (from file:///home/konsti/projects/uv/scripts/workspaces/albatross-virtual-workspace/packages/seeds) + sniffio==1.3.1 Traceback (most recent call last): File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'albatross' $ uv venv $ uv run --preview --package albatross python -c "import albatross" Built file:///home/konsti/projects/uv/scripts/workspaces/albatross-virtual-workspace/packages/albatross Built file:///home/konsti/projects/uv/scripts/workspaces/albatross-virtual-workspace/packages/bird-feeder Built file:///home/konsti/projects/uv/scripts/workspaces/albatross-virtual-workspace/packages/seeds Built 3 editables in 173ms Resolved 7 packages in 6ms Installed 7 packages in 1ms + albatross==0.1.0 (from file:///home/konsti/projects/uv/scripts/workspaces/albatross-virtual-workspace/packages/albatross) + anyio==4.4.0 + bird-feeder==1.0.0 (from file:///home/konsti/projects/uv/scripts/workspaces/albatross-virtual-workspace/packages/bird-feeder) + idna==3.6 + seeds==1.0.0 (from file:///home/konsti/projects/uv/scripts/workspaces/albatross-virtual-workspace/packages/seeds) + sniffio==1.3.1 + tqdm==4.66.4 ``` In albatross-root-workspace: ```console $ uv venv $ uv run --preview --package bird-feeder python -c "import albatross" Using Python 3.12.3 interpreter at: /home/konsti/.local/bin/python3 Creating virtualenv at: .venv Activate with: source .venv/bin/activate Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s Running `/home/konsti/projects/uv/target/debug/uv run --preview --package bird-feeder python -c 'import albatross'` Built file:///home/konsti/projects/uv/scripts/workspaces/albatross-root-workspace/packages/bird-feeder Built file:///home/konsti/projects/uv/scripts/workspaces/albatross-root-workspace/packages/seeds Built 2 editables in 161ms Resolved 5 packages in 4ms Installed 5 packages in 1ms + anyio==4.4.0 + bird-feeder==1.0.0 (from file:///home/konsti/projects/uv/scripts/workspaces/albatross-root-workspace/packages/bird-feeder) + idna==3.6 + seeds==1.0.0 (from file:///home/konsti/projects/uv/scripts/workspaces/albatross-root-workspace/packages/seeds) + sniffio==1.3.1 Traceback (most recent call last): File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'albatross' $ uv venv $ cargo run run --preview --package albatross python -c "import albatross" Using Python 3.12.3 interpreter at: /home/konsti/.local/bin/python3 Creating virtualenv at: .venv Activate with: source .venv/bin/activate Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.13s Running `/home/konsti/projects/uv/target/debug/uv run --preview --package albatross python -c 'import albatross'` Built file:///home/konsti/projects/uv/scripts/workspaces/albatross-root-workspace Built file:///home/konsti/projects/uv/scripts/workspaces/albatross-root-workspace/packages/bird-feeder Built file:///home/konsti/projects/uv/scripts/workspaces/albatross-root-workspace/packages/seeds Built 3 editables in 168ms Resolved 7 packages in 5ms Installed 7 packages in 1ms + albatross==0.1.0 (from file:///home/konsti/projects/uv/scripts/workspaces/albatross-root-workspace) + anyio==4.4.0 + bird-feeder==1.0.0 (from file:///home/konsti/projects/uv/scripts/workspaces/albatross-root-workspace/packages/bird-feeder) + idna==3.6 + seeds==1.0.0 (from file:///home/konsti/projects/uv/scripts/workspaces/albatross-root-workspace/packages/seeds) + sniffio==1.3.1 + tqdm==4.66.4 ```
eac4c00
to
82e22c7
Compare
Not sure what's up with the Windows failure. |
69e18d9
to
b9d2295
Compare
It passes without error on my Windows machine. |
cadb7f3
to
3c3037c
Compare
Some bad bug here because Windows is getting the following members (the names don't match the contents):
|
2d1469f
to
b12b95c
Compare
b12b95c
to
44c6e80
Compare
Sorry, I think I was being misled by the filters. I suspect the bug is in comparing the installed vs. requested path or something. |
Like we're using absolute vs. canonical paths either when defining the requirement or installing, but not being consistent between them. |
Okay yeah, the installed distribution has: But the requirement is: |
825c97c
to
5658838
Compare
5658838
to
94b195e
Compare
I hopefully fixed it by respecting symlinks in |
e00d444
to
742440e
Compare
Add a
--package
option that allows switching the current project in the workspace. Wherever you are in a workspace, you should be able to run with any other project as root. This is the uv equivalent ofcargo run -p
.I don't love the
--package
name, esp. since-p
is already taken and in general to many things start with p already.Part of this change is moving the workspace discovery of
ProjectWorkspace
toWorkspace
itself.Usage
In albatross-virtual-workspace:
In albatross-root-workspace: