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 --python-platform to sync and install commands #3154

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

charliermarsh
Copy link
Member

Summary

pip supports providing a --platform to pip install, which can be used to seed an environment (e.g., for use in a container or otherwise). This PR adds --python-platform to our commands to support a similar workflow. It has some caveats, which are documented on the CLI.

Closes #2079.

@charliermarsh charliermarsh added enhancement New feature or request cli Related to the command line interface labels Apr 20, 2024
@charliermarsh charliermarsh marked this pull request as ready for review April 20, 2024 00:16
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.

I was having deja vu here, because I thought I had reviewed a change like this already. I did some digging and:

So with all that context, I think this change makes sense, but:

  • Can we add a test covering this flag for the uv pip sync and uv pip install commands? I think we have a test for uv pip compile, but it would be good to cover the other two as well.
  • I mentioned this in a review comment, but what is the difference between pip's --platform and this --python-platform flag? And does there need to be a difference? Can we match what pip does instead?

crates/uv/src/cli.rs Show resolved Hide resolved
@zanieb
Copy link
Member

zanieb commented Apr 22, 2024

Can we add a test covering this flag for the uv pip sync and uv pip install commands? I think we have a test for uv pip compile, but it would be good to cover the other two as well.

Fwiw we've been intentionally not covering flags across every command. No comment on whether or not that's best.

@charliermarsh
Copy link
Member Author

(I'll answer your other question after goal setting, it's a good one to record in GitHub.)

@charliermarsh
Copy link
Member Author

...but what is the difference between pip's --platform and this --python-platform flag? And does there need to be a difference? Can we match what pip does instead?

Okay, so pip supports --platform, --abi, and --python-version. When provided, it basically takes those, and generates all the compatible target tags by generating combinations of the tree. If you provide --platform, you must either run with --no-deps or --only-binary :all:. And as far as I can tell, pip's --platform does not affect resolution (i.e., it does not change the markers; only the wheel tags).

So our --python-platform argument is slightly different. It's "higher-level", in that you describe a platform and then we generate the relevant wheel tags and markers. And we ship with fewer limitations, but with the risk that users may misuse the flag and create broken environments.

@charliermarsh charliermarsh merged commit 8536e63 into main Apr 22, 2024
39 checks passed
@charliermarsh charliermarsh deleted the charlie/install branch April 22, 2024 23:31
/// WARNING: When specified, uv will select wheels that are compatible with the target platform.
/// The resulting environment may not be fully compatible with the current platform. Further,
/// distributions that are built from source may ultimately be incompatible with the target
/// platform. This option is intended for cross-compilation and other advanced use cases.

Choose a reason for hiding this comment

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

This last sentence is confusing given the preceding paragraph, perhaps you meant

Suggested change
/// platform. This option is intended for cross-compilation and other advanced use cases.
/// platform. This option is not intended for cross-compilation and other advanced use cases.

?

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 think "cross-compilation" is the wrong term. It is intended for advanced use-cases, but "cross-compilation" emphasizes building from source in the wrong way.

Choose a reason for hiding this comment

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

Ah, okay. Yeah, I was definitely also mislead by the preceding sentence that specifically talks about building from source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command line interface enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cross-platform support
5 participants