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

Add support for configuring the python-preference with UV_PYTHON_PREFERENCE #6432

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ pub struct GlobalArgs {
global = true,
long,
help_heading = "Python options",
display_order = 700
display_order = 700,
env = "UV_PYTHON_PREFERENCE"
)]
pub python_preference: Option<PythonPreference>,

Expand Down
32 changes: 18 additions & 14 deletions crates/uv/tests/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ fn help() {

Python options:
--python-preference <PYTHON_PREFERENCE>
Whether to prefer uv-managed or system Python installations [possible values:
only-managed, managed, system, only-system]
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

Expand Down Expand Up @@ -101,8 +101,8 @@ fn help_flag() {

Python options:
--python-preference <PYTHON_PREFERENCE>
Whether to prefer uv-managed or system Python installations [possible values:
only-managed, managed, system, only-system]
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

Expand Down Expand Up @@ -162,8 +162,8 @@ fn help_short_flag() {

Python options:
--python-preference <PYTHON_PREFERENCE>
Whether to prefer uv-managed or system Python installations [possible values:
only-managed, managed, system, only-system]
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

Expand Down Expand Up @@ -274,6 +274,8 @@ fn help_subcommand() {
By default, uv prefers using Python versions it manages. However, it will use system
Python installations if a uv-managed Python is not installed. This option allows
prioritizing or ignoring system Python installations.

[env: UV_PYTHON_PREFERENCE=]

Possible values:
- only-managed: Only use managed Python installations; never use system Python
Expand Down Expand Up @@ -421,6 +423,8 @@ fn help_subsubcommand() {
By default, uv prefers using Python versions it manages. However, it will use system
Python installations if a uv-managed Python is not installed. This option allows
prioritizing or ignoring system Python installations.

[env: UV_PYTHON_PREFERENCE=]

Possible values:
- only-managed: Only use managed Python installations; never use system Python
Expand Down Expand Up @@ -531,8 +535,8 @@ fn help_flag_subcommand() {

Python options:
--python-preference <PYTHON_PREFERENCE>
Whether to prefer uv-managed or system Python installations [possible values:
only-managed, managed, system, only-system]
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

Expand Down Expand Up @@ -583,8 +587,8 @@ fn help_flag_subsubcommand() {

Python options:
--python-preference <PYTHON_PREFERENCE>
Whether to prefer uv-managed or system Python installations [possible values:
only-managed, managed, system, only-system]
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

Expand Down Expand Up @@ -715,8 +719,8 @@ fn help_with_global_option() {

Python options:
--python-preference <PYTHON_PREFERENCE>
Whether to prefer uv-managed or system Python installations [possible values:
only-managed, managed, system, only-system]
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

Expand Down Expand Up @@ -814,8 +818,8 @@ fn help_with_no_pager() {

Python options:
--python-preference <PYTHON_PREFERENCE>
Whether to prefer uv-managed or system Python installations [possible values:
only-managed, managed, system, only-system]
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

Expand Down
2 changes: 2 additions & 0 deletions docs/configuration/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ uv accepts the following command-line arguments as environment variables:
directories.
- `UV_EXCLUDE_NEWER`: Equivalent to the `--exclude-newer` command-line argument. If set, uv will
exclude distributions published after the specified date.
- `UV_PYTHON_PREFERENCE`: Equivalent to the `--python-preference` command-line argument. Whether uv
should prefer system or managed Python versions.

In each case, the corresponding command-line argument takes precedence over an environment variable.

Expand Down
Loading