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 requires-python to uv init #5322

Merged
merged 2 commits into from
Jul 23, 2024
Merged

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Jul 23, 2024

Summary

Prefers, in order:

  • The major-minor version of an interpreter discovered via --python.
  • The requires-python from the workspace.
  • The major-minor version of the default interpreter.

If the --python request is a version or a version range, we use that without fetching an interpreter.

Closes #5299.

@charliermarsh charliermarsh added bug Something isn't working preview Experimental behavior labels Jul 23, 2024
)
.await?
.into_interpreter();
RequiresPython::greater_than_equal_version(&interpreter.python_minor_version())
Copy link
Member Author

Choose a reason for hiding this comment

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

@zanieb - Can you review that what I'm doing with the discovery here is reasonable?

@FishAlchemist
Copy link
Contributor

FishAlchemist commented Jul 23, 2024

image
Should we avoid creating pyproject.toml when providing python version causes an error?
This is because creating it would lead to Project is already initialized.
image
A failed creation will result in pyproject.toml being created, but missing requires-python
e.g.

[project]
name = "www"
version = "0.1.0"

@charliermarsh
Copy link
Member Author

Yeah... Though unfortunately we need to create the pyproject.toml to discover the workspace :(

I'll figure something out.

@j178
Copy link
Contributor

j178 commented Jul 23, 2024

Just a heads-up,cargo init checks workspace.members glob pattern before creating the project:

https://github.com/rust-lang/cargo/blob/7f2079838ac6e0a3cb05b1b9dac4401a76572855/src/cargo/ops/cargo_new.rs#L978-L996

@charliermarsh
Copy link
Member Author

@j178 - We also check that before modifying the workspace manifest.

@charliermarsh charliermarsh enabled auto-merge (squash) July 23, 2024 15:54
@charliermarsh charliermarsh merged commit 0f8186d into main Jul 23, 2024
54 of 55 checks passed
@charliermarsh charliermarsh deleted the charlie/init-requires-python branch July 23, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uv init creates project with warning about Requires-Python
5 participants