From e92147f52a3f32818588e968f4be9315c8c35635 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Tue, 27 May 2025 04:44:39 +0100 Subject: [PATCH] [travis-ci] debugging ci failures on travis (#2387) * [travis-ci] debugging ci failures on travis * [travis-ci] Use JSON to encode env vars * [travis-ci] Use a more broadly compatible before_all command * Drop CIBW_ENABLE=all on Travis windows It doesn't fit into the time limit * [travis-ci] try upgrading certifi to get around SSL errors * Revert "[travis-ci] try upgrading certifi to get around SSL errors" This reverts commit 02eee0e1946d2116d1ce23ccd86945ad33d1ae24. * [travis-ci] upgrade windows certificates * [travis-ci] re-enable linux builds * Drop CIBW_ENABLE=all on Travis Linux It doesn't fit into the time limit --------- Co-authored-by: mayeut --- .travis.yml | 10 +++++++-- cibuildwheel/platforms/windows.py | 37 +++++++++++++------------------ test/test_before_all.py | 13 ++++++----- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index e4d1d72a..d2082cc1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,8 @@ jobs: services: docker env: - PYTHON=python - - CIBW_ENABLE=all + # a build using CIBW_ENABLE=all does not fit into Travis' time limit, + # so only the defaults are tested - name: Linux | arm64 | Python 3.12 python: 3.12 @@ -42,10 +43,15 @@ jobs: os: windows language: shell before_install: + # http://woshub.com/updating-trusted-root-certificates-in-windows-10 + - certutil -generateSSTFromWU roots.sst + - powershell -Command 'Get-ChildItem -Path roots.sst | Import-Certificate -CertStoreLocation Cert:\LocalMachine\Root' + - rm -f roots.sst - choco upgrade python3 -y --version 3.12.8 --limit-output --params "/InstallDir:C:\\Python312" env: - PYTHON=C:\\Python312\\python - - CIBW_ENABLE=all + # a build using CIBW_ENABLE=all does not fit into Travis' time limit, + # so only the defaults are tested - name: Linux | s390x | Python 3.12 python: 3.12 diff --git a/cibuildwheel/platforms/windows.py b/cibuildwheel/platforms/windows.py index 4e59275b..52e081f7 100644 --- a/cibuildwheel/platforms/windows.py +++ b/cibuildwheel/platforms/windows.py @@ -1,3 +1,4 @@ +import json import os import platform as platform_module import shutil @@ -350,28 +351,22 @@ def setup_python( text=True, ).strip() log.notice(f"Discovering Visual Studio for GraalPy at {vcpath}") - env.update( - dict( - [ - envvar.strip().split("=", 1) - for envvar in subprocess.check_output( - [ - f"{vcpath}\\Common7\\Tools\\vsdevcmd.bat", - "-no_logo", - "-arch=amd64", - "-host_arch=amd64", - "&&", - "set", - ], - shell=True, - text=True, - env=env, - ) - .strip() - .split("\n") - ] - ) + vcvars = subprocess.check_output( + [ + f"{vcpath}\\Common7\\Tools\\vsdevcmd.bat", + "-no_logo", + "-arch=amd64", + "-host_arch=amd64", + "&&", + "python", + "-c", + "import os, json, sys; json.dump(dict(os.environ), sys.stdout);", + ], + shell=True, + text=True, + env=env, ) + env.update(json.loads(vcvars)) return base_python, env diff --git a/test/test_before_all.py b/test/test_before_all.py index c7ec8624..f0c89972 100644 --- a/test/test_before_all.py +++ b/test/test_before_all.py @@ -36,16 +36,19 @@ def test(tmp_path): with (project_dir / "text_info.txt").open(mode="w") as ff: print("dummy text", file=ff) - # build the wheels + # write python version information to a temporary file, this is checked in + # setup.py + # + # note, before_all runs in whatever the host environment is, `python` + # might be any version of python (even Python 2 on Travis ci!), so this is + # written to be broadly compatible before_all_command = ( - """python -c "import os, pathlib, sys; pathlib.Path('{project}/text_info.txt').write_text('sample text '+os.environ.get('TEST_VAL', ''))" && """ - '''python -c "import pathlib, sys; pathlib.Path('{project}/python_prefix.txt').write_text(sys.prefix)"''' + """python -c "import os, sys; f = open('{project}/text_info.txt', 'w'); f.write('sample text '+os.environ.get('TEST_VAL', '')); f.close()" && """ + '''python -c "import sys; f = open('{project}/python_prefix.txt', 'w'); f.write(sys.prefix); f.close()"''' ) actual_wheels = utils.cibuildwheel_run( project_dir, add_env={ - # write python version information to a temporary file, this is - # checked in setup.py "CIBW_BEFORE_ALL": before_all_command, "CIBW_BEFORE_ALL_LINUX": f'{before_all_command} && python -c "import sys; assert sys.version_info >= (3, 8)"', "CIBW_ENVIRONMENT": "TEST_VAL='123'",