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 option to specify additional markers for wheel build requirements #129949

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions script/gen_requirements_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,40 @@
# will be included in requirements_all_{action}.txt

OVERRIDDEN_REQUIREMENTS_ACTIONS = {
"pytest": {"exclude": set(), "include": {"python-gammu"}},
"wheels_aarch64": {"exclude": set(), "include": INCLUDED_REQUIREMENTS_WHEELS},
"pytest": {
"exclude": set(),
"include": {"python-gammu"},
"markers": {},
},
"wheels_aarch64": {
"exclude": set(),
"include": INCLUDED_REQUIREMENTS_WHEELS,
"markers": {},
},
# Pandas has issues building on armhf, it is expected they
# will drop the platform in the near future (they consider it
# "flimsy" on 386). The following packages depend on pandas,
# so we comment them out.
"wheels_armhf": {
"exclude": {"env-canada", "noaa-coops", "pyezviz", "pykrakenapi"},
"include": INCLUDED_REQUIREMENTS_WHEELS,
"markers": {},
},
"wheels_armv7": {
"exclude": set(),
"include": INCLUDED_REQUIREMENTS_WHEELS,
"markers": {},
},
"wheels_amd64": {
"exclude": set(),
"include": INCLUDED_REQUIREMENTS_WHEELS,
"markers": {},
},
"wheels_i386": {
"exclude": set(),
"include": INCLUDED_REQUIREMENTS_WHEELS,
"markers": {},
},
"wheels_armv7": {"exclude": set(), "include": INCLUDED_REQUIREMENTS_WHEELS},
"wheels_amd64": {"exclude": set(), "include": INCLUDED_REQUIREMENTS_WHEELS},
"wheels_i386": {"exclude": set(), "include": INCLUDED_REQUIREMENTS_WHEELS},
}

IGNORE_PIN = ("colorlog>2.1,<3", "urllib3")
Expand Down Expand Up @@ -313,6 +334,10 @@ def process_action_requirement(req: str, action: str) -> str:
return req
if normalized_package_name in EXCLUDED_REQUIREMENTS_ALL:
return f"# {req}"
if markers := OVERRIDDEN_REQUIREMENTS_ACTIONS[action]["markers"].get(
normalized_package_name, None
):
return f"{req};{markers}"
return req


Expand Down
26 changes: 26 additions & 0 deletions tests/script/test_gen_requirements_all.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Tests for the gen_requirements_all script."""

from unittest.mock import patch

from script import gen_requirements_all


Expand All @@ -23,3 +25,27 @@ def test_include_overrides_subsets() -> None:
for overrides in gen_requirements_all.OVERRIDDEN_REQUIREMENTS_ACTIONS.values():
for req in overrides["include"]:
assert req in gen_requirements_all.EXCLUDED_REQUIREMENTS_ALL


def test_requirement_override_markers() -> None:
"""Test override markers are applied to the correct requirements."""
data = {
"pytest": {
"exclude": set(),
"include": set(),
"markers": {"env-canada": "python_version<'3.13'"},
}
}
with patch.dict(
gen_requirements_all.OVERRIDDEN_REQUIREMENTS_ACTIONS, data, clear=True
):
assert (
gen_requirements_all.process_action_requirement(
"env-canada==0.7.2", "pytest"
)
== "env-canada==0.7.2;python_version<'3.13'"
)
assert (
gen_requirements_all.process_action_requirement("other==1.0", "pytest")
== "other==1.0"
)