Summary
prek always pass --python-preference managed to uv,
so the python version priority used by the uv created virtualenv is:
- already downloaded uv managed python
- system python (python inside PATH)
- uv download the required python
This surprises me that a uv python installation can change the python used by prek.
Bug: prek does not handle language_version: system of python, in .pre-commit-config.yaml,
--python is not passed to uv, and --python-preference managed is still passed to uv
Also, for my usage, I would like to always prefer system python,
so there is more predicted behavior of the python chosen,
that I can ensure a specific python by controlling the PATH env var.
I have tried to set the env var UV_PYTHON, so it seems prek has intentionally cleared it.
I have also tried to set the env var UV_PYTHON_PREFERENCE, but it has no effect if --python-preference managed is specified.
I am not sure that if prek needs to specify --python-preference managed , because managed is the default of uv.
And I do not see any reference of --python-reference in the --help of uv and the doc of uv. It seems to be a hidden option. If prek` does not specify the preference, then it is possible for me to specify the preference in by env var, or by uv configuration file.
If there is concern to always remove --python-preference managed, may be it's better to add prek specific env var to control the preference.
Willing to submit a PR?
Platform
Linux 4.18.0-553.el8_10.x86_64 x86_64 GNU/Linux (RHEL8)
Version
0.4.3
.pre-commit-config.yaml
Log file
Summary
prekalways pass--python-preference managedtouv,so the python version priority used by the uv created virtualenv is:
This surprises me that a uv python installation can change the python used by
prek.Bug:
prekdoes not handlelanguage_version: systemof python, in .pre-commit-config.yaml,--pythonis not passed touv, and--python-preference managedis still passed touvAlso, for my usage, I would like to always prefer system python,
so there is more predicted behavior of the python chosen,
that I can ensure a specific python by controlling the PATH env var.
I have tried to set the env var
UV_PYTHON, so it seemsprekhas intentionally cleared it.I have also tried to set the env var
UV_PYTHON_PREFERENCE, but it has no effect if--python-preference managedis specified.I am not sure that if
prekneeds to specify--python-preference managed, becausemanagedis the default of uv.And I do not see any reference of
--python-referencein the--helpof uv and the doc of uv. It seems to be a hidden option. Ifprek` does not specify the preference, then it is possible for me to specify the preference in by env var, or by uv configuration file.If there is concern to always remove
--python-preference managed, may be it's better to add prek specific env var to control the preference.Willing to submit a PR?
Platform
Linux 4.18.0-553.el8_10.x86_64 x86_64 GNU/Linux (RHEL8)
Version
0.4.3
.pre-commit-config.yaml
Log file