Skip to content

Commit 30e76ec

Browse files
committed
Use a more broadly compatible before_all command
1 parent 643b41b commit 30e76ec

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/test_before_all.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ def test(tmp_path):
3636
with (project_dir / "text_info.txt").open(mode="w") as ff:
3737
print("dummy text", file=ff)
3838

39-
# build the wheels
39+
# write python version information to a temporary file, this is checked in
40+
# setup.py
41+
#
42+
# note, before_all runs in whatever the host environment is, `python`
43+
# might be any version of python (even Python 2 on Travis ci!), so this is
44+
# written to be broadly compatible
4045
before_all_command = (
41-
"""python -c "import os, pathlib, sys; pathlib.Path('{project}/text_info.txt').write_text('sample text '+os.environ.get('TEST_VAL', ''))" && """
42-
'''python -c "import pathlib, sys; pathlib.Path('{project}/python_prefix.txt').write_text(sys.prefix)"'''
46+
"""python -c "import os, sys; f = open('{project}/text_info.txt', 'w'); f.write('sample text '+os.environ.get('TEST_VAL', '')); f.close()" && """
47+
'''python -c "import sys; f = open('{project}/python_prefix.txt', 'w'); f.write(sys.prefix); f.close()"'''
4348
)
4449
actual_wheels = utils.cibuildwheel_run(
4550
project_dir,
4651
add_env={
47-
# write python version information to a temporary file, this is
48-
# checked in setup.py
4952
"CIBW_BEFORE_ALL": before_all_command,
5053
"CIBW_BEFORE_ALL_LINUX": f'{before_all_command} && python -c "import sys; assert sys.version_info >= (3, 8)"',
5154
"CIBW_ENVIRONMENT": "TEST_VAL='123'",

0 commit comments

Comments
 (0)