-
-
Notifications
You must be signed in to change notification settings - Fork 639
feat(pypi): pip.defaults API for customizing pipstar 1/n #2987
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
Changes from 1 commit
cd4dd15
d5a0645
7ef85aa
36cd97c
c459371
3ecc713
272f884
b10afe5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,9 +15,7 @@ | |
| """A simple function that evaluates markers using a python interpreter.""" | ||
|
|
||
| load(":deps.bzl", "record_files") | ||
| load(":pep508_env.bzl", "env") | ||
| load(":pep508_evaluate.bzl", "evaluate") | ||
| load(":pep508_platform.bzl", "platform_from_str") | ||
| load(":pep508_requirement.bzl", "requirement") | ||
| load(":pypi_repo_utils.bzl", "pypi_repo_utils") | ||
|
|
||
|
|
@@ -30,22 +28,26 @@ SRCS = [ | |
| Label("//python/private/pypi/whl_installer:platform.py"), | ||
| ] | ||
|
|
||
| def evaluate_markers(requirements, python_version = None): | ||
| def evaluate_markers(*, requirements, platforms): | ||
| """Return the list of supported platforms per requirements line. | ||
|
|
||
| Args: | ||
| requirements: {type}`dict[str, list[str]]` of the requirement file lines to evaluate. | ||
| python_version: {type}`str | None` the version that can be used when evaluating the markers. | ||
| platforms: {type}`dict[str | struct]` TODO | ||
|
|
||
| Returns: | ||
| dict of string lists with target platforms | ||
| """ | ||
| ret = {} | ||
| for req_string, platforms in requirements.items(): | ||
| for req_string, platform_strings in requirements.items(): | ||
| req = requirement(req_string) | ||
| for platform in platforms: | ||
| if evaluate(req.marker, env = env(platform_from_str(platform, python_version))): | ||
| ret.setdefault(req_string, []).append(platform) | ||
| for platform_str in platform_strings: | ||
| env = platforms.get(platform_str) | ||
| if not env: | ||
| fail("Please define platform: '{}'".format(platform_str)) | ||
|
|
||
| if evaluate(req.marker, env = env): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We evaluate during the bzlmod phase to basically pre-filter, right? e.g if you have
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. |
||
| ret.setdefault(req_string, []).append(platform_str) | ||
|
|
||
| return ret | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.