mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
![]() 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. Part of this change is moving the workspace discovery of `ProjectWorkspace` to `Workspace` itself. ## 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 ``` |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |