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

Support registering target platforms with the pip bzlmod extension #1606

Open
aignas opened this issue Dec 13, 2023 · 1 comment
Open

Support registering target platforms with the pip bzlmod extension #1606

aignas opened this issue Dec 13, 2023 · 1 comment
Assignees

Comments

@aignas
Copy link
Collaborator

aignas commented Dec 13, 2023

See comment #1593 (comment) for context.

The outline of the potential API is:

pip.register_platform(
    name = "linux_x86_64",
    cpu = "@platforms//cpu:x86_64",
    os = "@platforms//os:linux",
)

By default rules_python could register sensible values that the hermetic toolchain supports, but the user may elect to override the values by registering values in the root module. As such the proposal would be clear the values registered by rules_python if the root module registers any platform values.

One more idea would be to require the requirements_windows, etc based on the registered platforms.

This feature only starts making sense once #1593 is merged (refers to #1591) and this could help with finding a viable design for #260.

@rickeylev
Copy link
Collaborator

In slack, a potential use case for this came up: when you're using an alternative interpreter. As an example, there's 4 different builds of the x86_64 linux interpreter that vary by micro architecture, plus several more that very by some optimization settings. If a pypi package had distributions for such runtimes, then we'd need some way to map from those constraint settings to the wheel file.

In practice, I think the ones we've seen in the wild would be musl builds? A company using one of the specialized interpreters (or a custom interpreter) that stands up its own pypi index with custom-built wheels isn't out of the realm of plausibility, either.

(As an aside, this made me think that a solution to the "how do we use the correct interpreter in pip.parse?" / "how do we tell pip.parse what platforms it should care about?" problems is to not try and do that in pip.parse, and instead have e.g. compile_pip_requirements (which can do toolchain resolution) generate everything so that all pip.parse does is basically just calling http_archive() on a bunch of URLs).

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

No branches or pull requests

2 participants