Skip to content

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

Merged
merged 8 commits into from
Jun 19, 2025

Conversation

aignas
Copy link
Collaborator

@aignas aignas commented Jun 14, 2025

Parse env markers in pip.parse using starlark

Summary:

  • Allow switching to the Starlark implementation of the marker
    evaluation function.
  • Add a way for users to modify the env for the marker evaluation when
    parsing the requirements. This can only be done by rules_python or
    the root module.
  • Limit the platform selection when parsing the requirements files.

Work towards #2747
Work towards #2949
Split out from #2909

@aignas aignas requested review from rickeylev and groodt as code owners June 14, 2025 02:49
Summary:
- Allow switching to the Starlark implementation of the marker
  evaluation function.
- Add a way for users to modify the `env` for the marker evaluation when
  parsing the requirements. This can only be done by `rules_python` or
  the root module.
- Limit the platform selection when parsing the requirements files.

Work towards bazel-contrib#2747
Work towards bazel-contrib#2949
Split out from bazel-contrib#2909
@aignas aignas force-pushed the feat/pypi-default-1 branch from 14c0ff9 to cd4dd15 Compare June 14, 2025 03:03
@aignas aignas changed the title feat(pypi): parse env markers in pip.parse using starlark feat(pypi): pip.defaults API for customizing pipstar 1/n Jun 14, 2025
if not env:
fail("Please define platform: '{}'".format(platform_str))

if evaluate(req.marker, env = env):
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 {"linux": "requirements_universal.txt"}, then we're basically stripping out all the foo; os=="windows" lines so that we don't bother traversing (in the index) anything for foo for linux, and also avoid generating any targets for foo (for linux, anyways)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct.

@aignas aignas enabled auto-merge June 19, 2025 06:42
@aignas aignas added this pull request to the merge queue Jun 19, 2025
Merged via the queue into bazel-contrib:main with commit 5b1db07 Jun 19, 2025
3 checks passed
@aignas aignas deleted the feat/pypi-default-1 branch June 20, 2025 00:17
github-merge-queue bot pushed a commit that referenced this pull request Jun 20, 2025
WIP: stacked on #2987

This is adding `constraint_values` attribute to `pip.configure` and is
threading it all the way down to the generation of `BUILD.bazel` file of
for
config settings used in the hub repository.

Out of scope:
- Passing `flag_values` or target settings. I am torn about it - doing
it in
this PR would flesh out the design more, but at the same time it might
become
  harder to review.
- `whl_target_platforms` and `select_whls` is still unchanged, not sure
if it
  is related to this attribute addition.

Work towards #2747
Work towards #2548 
Work towards #260

---------

Co-authored-by: Richard Levasseur <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants