Skip to content

fix: Fix incorrectly generated Required-Dist when specifying requirements with markers in extra_requires in py_wheel rule - #2200

Merged
aignas merged 2 commits into
bazel-contrib:mainfrom
sfc-gh-wzhao:wzhao-allow-extras-in-py-wheel-requires-field
Sep 7, 2024
Merged

fix: Fix incorrectly generated Required-Dist when specifying requirements with markers in extra_requires in py_wheel rule#2200
aignas merged 2 commits into
bazel-contrib:mainfrom
sfc-gh-wzhao:wzhao-allow-extras-in-py-wheel-requires-field

Conversation

@sfc-gh-wzhao

Copy link
Copy Markdown
Contributor

Currently, if extra requirements are provided via a file, it is allowed to contain markers, but if it is passed via extra_requires field, it will run into error since the extra in this case is blindly added in the following line in py_wheel.bzl

metadata_contents.append(
    "Requires-Dist: %s; extra == '%s'" % (requirement, option),
)

Thus, this PR adds a post-process for this case, to make it possible to pass something like

    extra_requires = {"example": [
        "pyyaml>=6.0.0,!=6.0.1",
        'toml; (python_version == "3.11" or python_version == "3.12") and python_version != "3.8"',
        'wheel; python_version == "3.11" or python_version == "3.12" ',
    ]},

to py_wheel

@aignas aignas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@aignas
aignas added this pull request to the merge queue Sep 7, 2024
Merged via the queue into bazel-contrib:main with commit a18ae49 Sep 7, 2024
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