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 a universal resolution mode to pip compile #4505

Merged
merged 1 commit into from
Jun 25, 2024
Merged

Conversation

charliermarsh
Copy link
Member

Summary

This needs more tests and a few more changes, but checkpointing it for now.

@charliermarsh charliermarsh changed the title Add a universal resolution mode to pip compile Add a universal resolution mode to pip compile Jun 25, 2024
@charliermarsh charliermarsh added the enhancement New feature or improvement to existing functionality label Jun 25, 2024
Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

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

Hyped for supporting this

/// Perform a universal resolution, attempting to generate a single `requirements.txt` output
/// file that is compatible with all Python platforms.
#[arg(long, overrides_with("no_universal"))]
pub universal: bool,
Copy link
Member

Choose a reason for hiding this comment

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

🎉

@@ -568,6 +568,14 @@ pub struct PipCompileArgs {
#[arg(long)]
pub python_platform: Option<TargetTriple>,

/// Perform a universal resolution, attempting to generate a single `requirements.txt` output
/// file that is compatible with all Python platforms.
Copy link
Member

Choose a reason for hiding this comment

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

"Python platforms" is likely unclear to the users, we likely need something along the lines of "all operating systems, architectures and supported Python versions, as supported by your dependencies"

@charliermarsh charliermarsh force-pushed the charlie/universal branch 3 times, most recently from 9fd6651 to 2c3173d Compare June 25, 2024 12:18
};
let expr_python_full_version = MarkerExpression::Version {
key: MarkerValueVersion::PythonFullVersion,
specifier: VersionSpecifier::from_version(Operator::Equal, version).unwrap(),
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm a bit unsure of this. It still locks against the target Python version rather than "the target version at minimum." It's easy to change but not sure what the right semantics are.

Copy link
Member

Choose a reason for hiding this comment

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

My feeling is:

  • requires-python if the input is a pyproject.toml (the conjunction of all requires-python values if there are multiple pyproject.toml).
  • An explicit --requires-python argument.
  • >={{current python}} and inform the user that the should consider passing --requires-python if they want an interpreter independent resolution.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

that-was-easy-pressing-easy-button-5v06l34nfgfg8q2f

.requires_python()
.map(RequiresPython::to_marker_tree)
.unwrap_or_else(|| MarkerTree::And(vec![])),
)
Copy link
Member

Choose a reason for hiding this comment

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

Nice. You got rid of the MarkerTree::And(vec![])! I think the change is for the better right? My understanding is that now it will always have some non-empty marker expression in universal mode. So that when Requires-Python isn't provided, it will be based on the installed version of Python? Where as previously, there would be no filtering at all.

@charliermarsh charliermarsh force-pushed the charlie/req-txt branch 3 times, most recently from 63c943b to d41022e Compare June 25, 2024 20:49
Base automatically changed from charlie/req-txt to main June 25, 2024 20:56
@charliermarsh charliermarsh force-pushed the charlie/universal branch 2 times, most recently from 7e3b618 to a09c19e Compare June 25, 2024 21:10
@charliermarsh charliermarsh enabled auto-merge (squash) June 25, 2024 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants