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

uv venv should support respecting pyproject.toml #5552

Closed
Vigilans opened this issue Jul 29, 2024 · 0 comments · Fixed by #5592
Closed

uv venv should support respecting pyproject.toml #5552

Vigilans opened this issue Jul 29, 2024 · 0 comments · Fixed by #5592

Comments

@Vigilans
Copy link
Contributor

As per comment in #5258 (comment), uv venv may respect the requires-python config specified in pyproject.toml. This is a very useful feature to sync a python project not only with its dependencies, but also its python interpreter version.

Currently, seems that only uv sync can do this, but uv sync has a few shortcomings that makes it inconvenient to use. For example:

  • uv sync does not have --seed option: Synced venv does not have pip installed, and even if we manually install pip, the next time uv sync is executed the pip gets removed.
  • uv sync cannot have custom venv prompt set.
  • Custom user demands as specified in Expose more fine-grained control for uv sync command #5258

So, I think the feature described in this issue would be the entrypoint for user to tweak their environment with all dependencies (including python itself) specified in pyproject.toml, instead of having to pass the python version through command line or environment variables.

zanieb added a commit that referenced this issue Jul 31, 2024
)

<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

`uv venv` should support adopting python version specified in
`requires-python` from `pyproject.toml`. This allows customization on
the venv setup when syncing from python project.

Closes #5552.

It also serves as a workaround to close
#5258.

## Test Plan

<!-- How was it tested? -->

1. Run `uv venv` in folder with `pyroject.toml` specifying
`requries-python = "<3.10"`. Python 3.9 is selected for venv.
2. Change to `requries-python = "<3.11"` and run `uv venv` again. Python
3.10 is selected now.
3. Switch to a folder without `pyproject.toml` then run `uv venv`.
Python 3.12 is selected now.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
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 a pull request may close this issue.

1 participant