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

Python preference #70

Merged
merged 18 commits into from
Jul 29, 2024
Merged

Python preference #70

merged 18 commits into from
Jul 29, 2024

Conversation

RomainBrault
Copy link
Contributor

@RomainBrault RomainBrault commented Jul 26, 2024

This PR enables the usage of the flag --python-preference to better control which Python interpreter is used.

See https://docs.astral.sh/uv/python-versions/#adjusting-python-version-preferences

It does so by exposing a uv_python_preference configuration field.

Note: this can be used to download missing Python interpreter. Use for example

[testenv]
uv_python_preference = only-managed

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

tox-uv does not interact with uv python, only with uv venv. Doesn't the later only uses system pythons?

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

tox-uv does not interact with uv python, only with uv venv. Doesn't the later only uses system pythons?

@RomainBrault
Copy link
Contributor Author

tox-uv does not interact with uv python, only with uv venv. Doesn't the later only uses system pythons?

using python_preference = managed allows uv venv to use uv python toolchain if my understanding is correct.

I proposed this PR as it allows me to stop worrying about my python versions installed on my system and let tox-uv manage this through uv python.

By default no flag is passed to uv venv preserving the old behaviour. If python_preference is set, the flag --python-preference is passed, controlling wjether to use system python or some uv managed python.

@gaborbernat
Copy link
Member

using python_preference = managed allows uv venv to use uv python toolchain if my understanding is correct.

Can you link to upstream docs of this?

@RomainBrault
Copy link
Contributor Author

using python_preference = managed allows uv venv to use uv python toolchain if my understanding is correct.

Can you link to upstream docs of this?

https://docs.astral.sh/uv/python-versions/#adjusting-python-version-preferences

Should be in the README.md too.

src/tox_uv/_venv.py Outdated Show resolved Hide resolved
gaborbernat
gaborbernat previously approved these changes Jul 28, 2024
@gaborbernat
Copy link
Member

The CI is broken.

@RomainBrault
Copy link
Contributor Author

Blocking now with the typing error. Optional or Union[Type, None] are not working. Investigating.

@RomainBrault
Copy link
Contributor Author

At this point the CI pass locally

@gaborbernat
Copy link
Member

Seem it is not. Note you can setup https://github.com/RomainBrault/tox-uv/actions to not need to wait for my approval.

@RomainBrault
Copy link
Contributor Author

Here we go. I had to remove some type information to make it compatible with Python <3.10.

Thank you for your patience.

src/tox_uv/_venv.py Outdated Show resolved Hide resolved
Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

src/tox_uv/_venv.py Outdated Show resolved Hide resolved
src/tox_uv/_venv.py Outdated Show resolved Hide resolved
Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

@gaborbernat gaborbernat merged commit 1f398a0 into tox-dev:main Jul 29, 2024
22 checks passed
@bluss
Copy link

bluss commented Jul 30, 2024

I guess this is why I reported #72

I thought tox-uv didn't "do this" because it was not advertised, and some open issues suggested otherwise. This is a feature that has just turned up, because uv venv already does it depending on configuration (that I already had).

Oh and it's a preview feature in uv so in that sense I guess it makes sense to not make any guarantees about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants