Skip to content

Commit

Permalink
Add option to specify additional markers for wheel build requirements (
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored Nov 8, 2024
1 parent 9037cb8 commit 0a4c0fe
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
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 @@ -311,6 +332,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"
)

0 comments on commit 0a4c0fe

Please sign in to comment.