Skip to content

Commit 07a0347

Browse files
committed
Workaround GraalPy bugs on Windows
1 parent d4e5331 commit 07a0347

File tree

4 files changed

+52
-6
lines changed

4 files changed

+52
-6
lines changed

cibuildwheel/platforms/windows.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,19 @@ def build(options: Options, tmp_path: Path) -> None:
417417
for config in python_configurations:
418418
build_options = options.build_options(config.identifier)
419419
build_frontend = build_options.build_frontend or BuildFrontendConfig("build")
420+
421+
if (
422+
config.identifier.startswith("gp")
423+
and build_frontend.name == "build"
424+
and "--no-isolation" not in build_frontend.args
425+
and "-n" not in build_frontend.args
426+
):
427+
# GraalPy fails to discover its standard library when a venv is created
428+
# from a virtualenv seeded executable. See
429+
# https://github.com/oracle/graalpython/issues/491 and remove this once
430+
# fixed upstream.
431+
build_frontend = BuildFrontendConfig("build[uv]", build_frontend.args)
432+
420433
use_uv = build_frontend.name == "build[uv]" and can_use_uv(config)
421434
log.build_start(config.identifier)
422435

@@ -493,6 +506,7 @@ def build(options: Options, tmp_path: Path) -> None:
493506
elif build_frontend.name == "build" or build_frontend.name == "build[uv]":
494507
if use_uv and "--no-isolation" not in extra_flags and "-n" not in extra_flags:
495508
extra_flags.append("--installer=uv")
509+
496510
call(
497511
"python",
498512
"-m",

test/test_before_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def test(tmp_path, build_frontend_env):
6363
# the 'false ||' bit is to ensure this command runs in a shell on
6464
# mac/linux.
6565
"CIBW_TEST_COMMAND": f"false || {utils.invoke_pytest()} {{project}}/test",
66-
"CIBW_TEST_COMMAND_WINDOWS": "pytest {project}/test",
66+
# pytest fails on GraalPy 24.2.0 on Windows so we skip it there
67+
# until https://github.com/oracle/graalpython/issues/490 is fixed
68+
"CIBW_TEST_COMMAND_WINDOWS": "where graalpy || pytest {project}/test",
6769
**build_frontend_env,
6870
},
6971
)

test/test_dependency_versions.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ def test_dependency_constraints(method, tmp_path, build_frontend_env_nouv):
125125

126126
build_environment = {}
127127

128+
if (
129+
utils.platform == "windows"
130+
and method == "file"
131+
and build_frontend_env_nouv["CIBW_BUILD_FRONTEND"] == "build"
132+
):
133+
# GraalPy fails to discover its standard library when a venv is created
134+
# from a virtualenv seeded executable. See
135+
# https://github.com/oracle/graalpython/issues/491 and remove this once
136+
# fixed upstream.
137+
build_frontend_env_nouv["CIBW_SKIP"] = "gp*"
138+
128139
for package_name, version in tool_versions.items():
129140
env_name = f"EXPECTED_{package_name.upper()}_VERSION"
130141
build_environment[env_name] = version
@@ -144,4 +155,13 @@ def test_dependency_constraints(method, tmp_path, build_frontend_env_nouv):
144155
# also check that we got the right wheels
145156
expected_wheels = utils.expected_wheels("spam", "0.1.0")
146157

158+
if (
159+
utils.platform == "windows"
160+
and method == "file"
161+
and build_frontend_env_nouv["CIBW_BUILD_FRONTEND"] == "build"
162+
):
163+
# See reference to https://github.com/oracle/graalpython/issues/491
164+
# above
165+
expected_wheels = [w for w in expected_wheels if "graalpy" not in w]
166+
147167
assert set(actual_wheels) == set(expected_wheels)

test/test_testing.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ def test(tmp_path):
8181
# the 'false ||' bit is to ensure this command runs in a shell on
8282
# mac/linux.
8383
"CIBW_TEST_COMMAND": f"false || {utils.invoke_pytest()} {{project}}/test",
84-
"CIBW_TEST_COMMAND_WINDOWS": "COLOR 00 || pytest {project}/test",
84+
# pytest fails on GraalPy 24.2.0 on Windows so we skip it there
85+
# until https://github.com/oracle/graalpython/issues/490 is fixed
86+
"CIBW_TEST_COMMAND_WINDOWS": "COLOR 00 || where graalpy || pytest {project}/test",
8587
},
8688
)
8789

@@ -102,7 +104,9 @@ def test_extras_require(tmp_path):
102104
# the 'false ||' bit is to ensure this command runs in a shell on
103105
# mac/linux.
104106
"CIBW_TEST_COMMAND": f"false || {utils.invoke_pytest()} {{project}}/test",
105-
"CIBW_TEST_COMMAND_WINDOWS": "COLOR 00 || pytest {project}/test",
107+
# pytest fails on GraalPy 24.2.0 on Windows so we skip it there
108+
# until https://github.com/oracle/graalpython/issues/490 is fixed
109+
"CIBW_TEST_COMMAND_WINDOWS": "COLOR 00 || where graalpy || pytest {project}/test",
106110
},
107111
single_python=True,
108112
)
@@ -134,7 +138,9 @@ def test_dependency_groups(tmp_path):
134138
# the 'false ||' bit is to ensure this command runs in a shell on
135139
# mac/linux.
136140
"CIBW_TEST_COMMAND": f"false || {utils.invoke_pytest()} {{project}}/test",
137-
"CIBW_TEST_COMMAND_WINDOWS": "COLOR 00 || pytest {project}/test",
141+
# pytest fails on GraalPy 24.2.0 on Windows so we skip it there
142+
# until https://github.com/oracle/graalpython/issues/490 is fixed
143+
"CIBW_TEST_COMMAND_WINDOWS": "COLOR 00 || where graalpy || pytest {project}/test",
138144
},
139145
single_python=True,
140146
)
@@ -189,7 +195,9 @@ def test_bare_pytest_invocation(tmp_path: Path, test_runner: str) -> None:
189195
add_env={
190196
"CIBW_TEST_REQUIRES": "pytest" if test_runner == "pytest" else "",
191197
"CIBW_TEST_COMMAND": (
192-
"python -m pytest"
198+
# pytest fails on GraalPy 24.2.0 on Windows so we skip it there
199+
# until https://github.com/oracle/graalpython/issues/490 fixed
200+
"graalpy.exe -c 1 || python -m pytest"
193201
if test_runner == "pytest"
194202
else "python -m unittest discover test spam_test.py"
195203
),
@@ -211,7 +219,9 @@ def test_test_sources(tmp_path):
211219
add_env={
212220
"CIBW_TEST_REQUIRES": "pytest",
213221
"CIBW_TEST_COMMAND": "pytest",
214-
"CIBW_TEST_COMMAND_WINDOWS": "pytest",
222+
# pytest fails on GraalPy 24.2.0 on Windows so we skip it there
223+
# until https://github.com/oracle/graalpython/issues/490 is fixed
224+
"CIBW_TEST_COMMAND_WINDOWS": "where graalpy || pytest",
215225
"CIBW_TEST_SOURCES": "test",
216226
},
217227
)

0 commit comments

Comments
 (0)