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

Fix list rendering in venv --help output #1459

Merged
merged 1 commit into from
Feb 16, 2024
Merged

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Feb 16, 2024

Summary

Use verbatim_doc_comment to preserve the formatting of the venv python command line option to avoid that the list formatting gets mangled.

I changed the lists to use - which is what clap uses to render possible options (see color) and removed the -p in front of each format (again, to match claps possible options rendering)

Fixes #1364

Test Plan

Create a virtual environment

Usage: uv venv [OPTIONS] [NAME]

Arguments:
  [NAME]
          The path to the virtual environment to create
          
          [default: .venv]

Options:
  -p, --python <PYTHON>
          The Python interpreter to use for the virtual environment.
          
          Supported formats:
          - `3.10` searches for an installed Python 3.10 (`py --list-paths` on Windows, `python3.10` on Linux/Mac).
            Specifying a patch version is not supported.
          - `python3.10` or `python.exe` looks for a binary in `PATH`.
          - `/home/ferris/.local/bin/python3.10` uses this exact Python.
          
          Note that this is different from `--python-version` in `pip compile`, which takes `3.10` or `3.10.13` and
          doesn't look for a Python interpreter on disk.

      --seed
          Install seed packages (`pip`, `setuptools`, and `wheel`) into the virtual environment

  -i, --index-url <INDEX_URL>
          The URL of the Python Package Index
          
          [env: UV_INDEX_URL=]
          [default: https://pypi.org/simple]

      --extra-index-url <EXTRA_INDEX_URL>
          Extra URLs of package indexes to use, in addition to `--index-url`

  -q, --quiet
          Do not print any output

      --no-index
          Ignore the registry index (e.g., PyPI), instead relying on direct URL dependencies and those discovered via `--find-links`

  -v, --verbose
          Use verbose output

      --offline
          Run offline, i.e., without accessing the network

      --color <COLOR>
          Control colors in output
          
          [default: auto]

          Possible values:
          - auto:   Enables colored output only when the output is going to a terminal or TTY with support
          - always: Enables colored output regardless of the detected environment
          - never:  Disables colored output

  -n, --no-cache
          Avoid reading from or writing to the cache
          
          [env: UV_NO_CACHE=]

      --cache-dir <CACHE_DIR>
          Path to the cache directory
          
          [env: UV_CACHE_DIR=]

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

@MichaReiser MichaReiser changed the title Fix venv help text for python version option Fix list rendering in venv --help output Feb 16, 2024
@MichaReiser MichaReiser force-pushed the python-version-help-text branch from 871d24c to 1c3d6e1 Compare February 16, 2024 09:26
@MichaReiser MichaReiser added the bug Something isn't working label Feb 16, 2024
Comment on lines -635 to +638
/// * `-p 3.10` searches for an installed Python 3.10 (`py --list-paths` on Windows, `python3.10` on Linux/Mac).
/// - `3.10` searches for an installed Python 3.10 (`py --list-paths` on Windows, `python3.10` on Linux/Mac).
/// Specifying a patch version is not supported.
/// * `-p python3.10` or `-p python.exe` looks for a binary in `PATH`.
/// * `-p /home/ferris/.local/bin/python3.10` uses this exact Python.
/// - `python3.10` or `python.exe` looks for a binary in `PATH`.
/// - `/home/ferris/.local/bin/python3.10` uses this exact Python.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we toggle the comment with cfg to have it be platform relevant? I think that'd make it a lot shorter and it wouldn't need to be listed like this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Happy to track this in a follow-up too)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, no if cfg applies to comments. We could define a custom struct for the Path and have two different definitions for each platform but that's a bit more involved (and requires copying the configuration)

@MichaReiser MichaReiser merged commit e913167 into main Feb 16, 2024
7 checks passed
@MichaReiser MichaReiser deleted the python-version-help-text branch February 16, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uv venv's -p help has incorrectly rendered list
3 participants