Skip to content

Commit 2025688

Browse files
Add BASE_IGNORED_REQUIREMENTS and rename
1 parent 64c515f commit 2025688

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

pyodide_build/cli/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"ldflags": "SIDE_MODULE_LDFLAGS",
2222
"meson_cross_file": "MESON_CROSS_FILE",
2323
"xbuildenv_path": "PYODIDE_XBUILDENV_PATH",
24-
"avoided_build_requirements": "AVOIDED_BUILD_REQUIREMENTS",
24+
"ignored_build_requirements": "IGNORED_BUILD_REQUIREMENTS",
2525
}
2626

2727

pyodide_build/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
exit_with_stdio,
1111
search_pyproject_toml,
1212
)
13+
from pyodide_build.constants import BASE_IGNORED_REQUIREMENTS
1314
from pyodide_build.logger import logger
14-
from pyodide_build.pypabuild import AVOIDED_REQUIREMENTS
1515

1616

1717
class ConfigManager:
@@ -200,7 +200,7 @@ def _get_make_environment_vars(self) -> Mapping[str, str]:
200200
"build_dependency_index_url": "BUILD_DEPENDENCY_INDEX_URL",
201201
"default_cross_build_env_url": "DEFAULT_CROSS_BUILD_ENV_URL",
202202
"xbuildenv_path": "PYODIDE_XBUILDENV_PATH",
203-
"avoided_build_requirements": "AVOIDED_BUILD_REQUIREMENTS",
203+
"ignored_build_requirements": "IGNORED_BUILD_REQUIREMENTS",
204204
# maintainer only
205205
"_f2c_fixes_wrapper": "_F2C_FIXES_WRAPPER",
206206
}
@@ -220,7 +220,7 @@ def _get_make_environment_vars(self) -> Mapping[str, str]:
220220
"build_dependency_index_url",
221221
"default_cross_build_env_url",
222222
"xbuildenv_path",
223-
"avoided_build_requirements",
223+
"ignored_build_requirements",
224224
# maintainer only
225225
"_f2c_fixes_wrapper",
226226
}
@@ -242,7 +242,8 @@ def _get_make_environment_vars(self) -> Mapping[str, str]:
242242
"build_dependency_index_url": "https://pypi.anaconda.org/pyodide/simple",
243243
"default_cross_build_env_url": "",
244244
"xbuildenv_path": "",
245-
"avoided_build_requirements": " ".join(AVOIDED_REQUIREMENTS),
245+
# A list of PEP508 build-time requirements to be ignored when building a wheel
246+
"ignored_build_requirements": " ".join(BASE_IGNORED_REQUIREMENTS),
246247
# maintainer only
247248
"_f2c_fixes_wrapper": "",
248249
}

pyodide_build/constants.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Some reusable constants that are used at various sources in our code.
2+
# TODO: collect and add more constants here.
3+
4+
BASE_IGNORED_REQUIREMENTS: list[str] = [
5+
# mesonpy installs patchelf in linux platform but we don't want it.
6+
"patchelf",
7+
"oldest-supported-numpy",
8+
]

pyodide_build/pypabuild.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@
3232
_ProjectBuilder,
3333
)
3434

35-
AVOIDED_REQUIREMENTS = [
36-
# mesonpy installs patchelf in linux platform but we don't want it.
37-
"patchelf",
38-
"oldest-supported-numpy",
39-
]
40-
41-
AVOIDED_REQUIREMENTS: list[str] = [
42-
"patchelf",
43-
"oldest-supported-numpy",
44-
] + get_host_build_flag("AVOIDED_BUILD_REQUIREMENTS").split()
45-
4635
# corresponding env variables for symlinks
4736
SYMLINK_ENV_VARS = {
4837
"cc": "CC",
@@ -103,6 +92,8 @@ def _runner(cmd, cwd=None, extra_environ=None):
10392

10493

10594
def symlink_unisolated_packages(env: DefaultIsolatedEnv) -> None:
95+
from pyodide_build.build_env import get_build_flag, get_unisolated_packages
96+
10697
pyversion = get_pyversion()
10798
site_packages_path = f"lib/{pyversion}/site-packages"
10899
env_site_packages = Path(env.path) / site_packages_path
@@ -137,14 +128,17 @@ def remove_avoided_requirements(
137128
def install_reqs(
138129
build_env: Mapping[str, str], env: DefaultIsolatedEnv, reqs: set[str]
139130
) -> None:
131+
IGNORED_BUILD_REQUIREMENTS = get_host_build_flag(
132+
"IGNORED_BUILD_REQUIREMENTS"
133+
).split()
140134
# propagate PIP config from build_env to current environment
141135
with common.replace_env(
142136
os.environ | {k: v for k, v in build_env.items() if k.startswith("PIP")}
143137
):
144138
env.install(
145139
remove_avoided_requirements(
146140
reqs,
147-
get_unisolated_packages() + AVOIDED_REQUIREMENTS,
141+
get_unisolated_packages() + IGNORED_BUILD_REQUIREMENTS,
148142
)
149143
)
150144

@@ -262,7 +256,6 @@ def make_command_wrapper_symlinks(symlink_dir: Path) -> dict[str, str]:
262256
-------
263257
The dictionary of compiler environment variables that points to the symlinks.
264258
"""
265-
266259
# For maintainers:
267260
# - you can set "_f2c_fixes_wrapper" variable in pyproject.toml
268261
# in order to change the script to use when cross-compiling
@@ -321,6 +314,7 @@ def get_build_env(
321314
Returns a dict of environment variables that should be used when building
322315
a package with pypa/build.
323316
"""
317+
from pyodide_build.build_env import get_build_flag
324318

325319
kwargs = {
326320
"pkgname": pkgname,

pyodide_build/tests/test_pypabuild.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def test_install_reqs(tmp_path, dummy_xbuildenv):
2727
for req in reqs:
2828
assert req in env.installed
2929

30-
pypabuild.install_reqs({}, env, set(pypabuild.AVOIDED_REQUIREMENTS)) # type: ignore[arg-type]
31-
for req in pypabuild.AVOIDED_REQUIREMENTS:
30+
pypabuild.install_reqs({}, env, set(pypabuild.BASE_IGNORED_REQUIREMENTS)) # type: ignore[arg-type]
31+
for req in pypabuild.BASE_IGNORED_REQUIREMENTS:
3232
assert req not in env.installed
3333

3434

0 commit comments

Comments
 (0)