# Inspiration | [`pdm venv`](https://pdm-project.org/latest/reference/cli/#venv) | [2022-07-15](https://pdm-project.org/en/latest/dev/changelog/#release-v200b1-2022-07-02) | [2.0.0](https://pdm-project.org/en/latest/dev/changelog/#release-v200b1-2022-07-02) | | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | | [`uv venv`](https://docs.astral.sh/uv/reference/cli/#uv-venv) | [2024-08-20](https://astral.sh/blog/uv-unified-python-packaging) | [0.3.0](https://astral.sh/blog/uv-unified-python-packaging) | ## PDM ``` Options: -h, --help: Show this help message and exit. -p, --project: Specify another path as the project root, which changes the base ofpyproject.toml and __pypackages__ [env var: PDM_PROJECT] --path: Show the path to the given virtualenv --python: Show the python interpreter path for the given virtualenv Commands: create# Create a virtualenv Positional Arguments: python: Specify which python should be used to create the virtualenv venv_args: Additional arguments that will be passed to the backend Options: -h, --help: Show this help message and exit. -v, --verbose: Use -v for detailed output and -vv for more detailed -q, --quiet: Suppress output -w, --with: Specify the backend to create the virtualenv -f, --force: Recreate if the virtualenv already exists -n, --name: Specify the name of the virtualenv --with-pip: Install pip with the virtualenv list# List all virtualenvs associated with this project Options: -h, --help: Show this help message and exit. -v, --verbose: Use -v for detailed output and -vv for more detailed -q, --quiet: Suppress output remove# Remove the virtualenv with the given name Positional Arguments: env: The key of the virtualenv Options: -h, --help: Show this help message and exit. -v, --verbose: Use -v for detailed output and -vv for more detailed -q, --quiet: Suppress output -y, --yes: Answer yes on the following question activate# Print the command to activate the virtualenv with the given name Positional Arguments: env: The key of the virtualenv Options: -h, --help: Show this help message and exit. -v, --verbose: Use -v for detailed output and -vv for more detailed -q, --quiet: Suppress output purge# Purge selected/all created Virtualenvs Options: -h, --help: Show this help message and exit. -v, --verbose: Use -v for detailed output and -vv for more detailed -q, --quiet: Suppress output -f, --force: Force purging without prompting for confirmation -i, --interactive: Interactively purge selected Virtualenvs ``` ## uv ``` 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 [env: UV_VENV_SEED=] -c, --clear Remove any existing files or directories at the target path [env: UV_VENV_CLEAR=] --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] --exclude-newer <EXCLUDE_NEWER> Limit candidate packages to those that were uploaded prior to the given date [env: UV_EXCLUDE_NEWER=] --exclude-newer-package <EXCLUDE_NEWER_PACKAGE> Limit candidate packages for a specific package to those that were uploaded prior to the given date --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=] --managed-python Require use of uv-managed Python versions [env: UV_MANAGED_PYTHON=] --no-managed-python Disable use of uv-managed Python versions [env: UV_NO_MANAGED_PYTHON=] --no-python-downloads Disable automatic downloads of Python. [env: "UV_PYTHON_DOWNLOADS=never"] Index options: --index <INDEX> The URLs to use when resolving dependencies, in addition to the default index [env: UV_INDEX=] --default-index <DEFAULT_INDEX> The URL of the default package index (by default: <https://pypi.org/simple>) [env: UV_DEFAULT_INDEX=] -i, --index-url <INDEX_URL> (Deprecated: use `--default-index` instead) The URL of the Python package index (by default: <https://pypi.org/simple>) [env: UV_INDEX_URL=] --extra-index-url <EXTRA_INDEX_URL> (Deprecated: use `--index` instead) 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 [env: UV_FIND_LINKS=] --no-index Ignore the registry index (e.g., PyPI), instead relying on direct URL dependencies and those provided via `--find-links` Cache options: --refresh Refresh all cached data -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=] --refresh-package <REFRESH_PACKAGE> Refresh cached data for a specific package --cache-dir <CACHE_DIR> Path to the cache directory [env: UV_CACHE_DIR=] Global options: -q, --quiet... Use quiet output -v, --verbose... Use verbose output --color <COLOR_CHOICE> Control the use of color in output [possible values: auto, always, never] --native-tls Whether to load TLS certificates from the platform's native certificate store [env: UV_NATIVE_TLS=] --offline Disable network access [env: UV_OFFLINE=] --allow-insecure-host <ALLOW_INSECURE_HOST> Allow insecure connections to a host [env: UV_INSECURE_HOST=] --no-progress Hide all progress outputs [env: UV_NO_PROGRESS=] --directory <DIRECTORY> Change to the given directory prior to running the command [env: UV_WORKING_DIR=] --project <PROJECT> Discover a project in the given directory [env: UV_PROJECT=] --config-file <CONFIG_FILE> The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] --no-config Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) [env: UV_NO_CONFIG=] -h, --help Display the concise help for this command Use `uv help venv` for more details. ``` # Purpose Create a virtual environment. # Ideas Requires [[Virtual environment location]] landing. - Create a virtual environment in `.venv` next to `pyproject.toml` (this should be the same as what `py run` would do if it was pointed at a project to create a virtual environment) - Provide a way to point to a preexisting or already active virtual environment - Be able to specify an alternative location - Provide the command to create the shell code to activate the virtual environment? - Probably not because if I did things right it won't be necessary - `--with-pip`; default - Install pip either into the virtual environment or use the `.pyz` - `=cached`: write a `.pth` that connects to `pip.pyz` as maintained for [[#`py ready`]] and then add a `bin/pip` command - What if the Python version isn't supported? - Convert to a local install via https://bootstrap.pypa.io/pip/ and `get-pip.py` or `ensurepip`? - Find the appropriate `pip.pyz` based on version support from PyPI simple index data? - `pip.pyz` errors out with a generic `1` exit code - Don't worry about it and let them take care of it themselves since they are using an unsupported version of Python? - `=local`: install into the virtual environment - Can you just unpack `pip.pyz` and then add `bin/pip`? - It lacks any packaging-related files, so no `.dist-info` - Is this necessary? Should users be told to rely on `-m venv` if they need a separate copy of pip? - Only necessary if you need a specific version of pip or running a Python version too old for the current `pip.pyz` - Both cases are rather unique - `get-pip.py` from https://bootstrap.pypa.io/pip/ will do a local install - Could use `ensurepip` (although what if a Linux distro left it out?is missing it?) - Is supporting global vs local even reasonable? - This only works if you either use the other commands that trigger pip to be updated or provide a specific command to update pip - Might just be best to make sure to download `get-pip.py` if necessary - Need an easy way to run entry points? - Other tools use their `run` command to accomplish this - Could have [[#`py tool`]] , [[#`py exec`]], or [[#`py run`]] handle this - Only really necessary in the face of a `.venv` file or convenience to leave off `.venv/bin/`