Skip to content
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

Feature suggestion: uv venv -a/--activate #8118

Closed
simonw opened this issue Oct 11, 2024 · 4 comments
Closed

Feature suggestion: uv venv -a/--activate #8118

simonw opened this issue Oct 11, 2024 · 4 comments
Labels
duplicate This issue or pull request already exists

Comments

@simonw
Copy link
Contributor

simonw commented Oct 11, 2024

I'm trying to retrain myself to use uv run ... instead of activating my virtual environment (see Twitter) but I still find myself sometimes wishing it was quicker to create and then activate a virtual environment.

So how about this?

uv venv -a
# which is a shortcut for:
uv venv --activate

This would have the exact same effect as running:

uv venv
source .venv/bin/activate
@simonw
Copy link
Contributor Author

simonw commented Oct 11, 2024

Current uv venv --help:

Create a virtual environment

Usage: uv venv [OPTIONS] [PATH]

Arguments:
  [PATH]  The path to the virtual environment to create

Options:
      --no-project
          Avoid discovering a project or workspace
      --seed
          Install seed packages (one or more of: `pip`, `setuptools`, and
          `wheel`) into the virtual environment
      --allow-existing
          Preserve any existing files or directories at the target path
      --prompt <PROMPT>
          Provide an alternative prompt prefix for the virtual environment.
      --system-site-packages
          Give the virtual environment access to the system site packages
          directory
      --relocatable
          Make the virtual environment relocatable
      --index-strategy <INDEX_STRATEGY>
          The strategy to use when resolving against multiple index URLs [env:
          UV_INDEX_STRATEGY=] [possible values: first-index, unsafe-first-match,
          unsafe-best-match]
      --keyring-provider <KEYRING_PROVIDER>
          Attempt to use `keyring` for authentication for index URLs [env:
          UV_KEYRING_PROVIDER=] [possible values: disabled, subprocess]
      --allow-insecure-host <ALLOW_INSECURE_HOST>
          Allow insecure connections to a host [env: UV_INSECURE_HOST=]
      --exclude-newer <EXCLUDE_NEWER>
          Limit candidate packages to those that were uploaded prior to the
          given date [env: UV_EXCLUDE_NEWER=]
      --link-mode <LINK_MODE>
          The method to use when installing packages from the global cache [env:
          UV_LINK_MODE=] [possible values: clone, copy, hardlink, symlink]

Python options:
  -p, --python <PYTHON>
          The Python interpreter to use for the virtual environment. [env:
          UV_PYTHON=]
      --python-preference <PYTHON_PREFERENCE>
          Whether to prefer uv-managed or system Python installations [env:
          UV_PYTHON_PREFERENCE=] [possible values: only-managed, managed,
          system, only-system]
      --no-python-downloads
          Disable automatic downloads of Python. [env:
          "UV_PYTHON_DOWNLOADS=never"]

Index options:
  -i, --index-url <INDEX_URL>
          The URL of the Python package index (by default:
          <https://pypi.org/simple>) [env: UV_INDEX_URL=]
      --extra-index-url <EXTRA_INDEX_URL>
          Extra URLs of package indexes to use, in addition to `--index-url`
          [env: UV_EXTRA_INDEX_URL=]
  -f, --find-links <FIND_LINKS>
          Locations to search for candidate distributions, in addition to those
          found in the registry indexes
      --no-index
          Ignore the registry index (e.g., PyPI), instead relying on direct URL
          dependencies and those provided via `--find-links`

Cache options:
  -n, --no-cache               Avoid reading from or writing to the cache,
                               instead using a temporary directory for the
                               duration of the operation [env: UV_NO_CACHE=]
      --cache-dir <CACHE_DIR>  Path to the cache directory [env: UV_CACHE_DIR=]

So it looks like -a is available as an unused shortcut.

@simonw
Copy link
Contributor Author

simonw commented Oct 11, 2024

Aside:

Create a virtual environment

Usage: uv venv [OPTIONS] [PATH]

Arguments:
  [PATH]  The path to the virtual environment to create

The --help output currently implies that PATH is a required argument, but it's not - running uv venv alone is equivalent to uv venv ..

@AlexWaygood
Copy link
Member

I believe this may be a duplicate of #8106 (sadly)

@zanieb
Copy link
Member

zanieb commented Oct 11, 2024

Yeah this is a duplicate — unfortunately this is a limitation of shells.

If we ever do #1910 we could support this.

@zanieb zanieb added the duplicate This issue or pull request already exists label Oct 11, 2024
@zanieb zanieb closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants