From 582c2eae173f156195f604dea913ca789d5cf8b6 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sun, 21 Jul 2024 14:37:10 +0200 Subject: [PATCH] wip --- .github/workflows/main.yml | 21 +++++++++++++++++++++ distutils/tests/__init__.py | 18 ++++++++++-------- distutils/tests/test_build_ext.py | 11 +++++++++-- pytest.ini | 1 - 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 70d70bc6..d81f1c4a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -163,6 +163,27 @@ jobs: source /tmp/venv/bin/activate pytest + test_msvc_mingw: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.x + - name: Install tox + run: python -m pip install tox + - name: Install GCC + uses: msys2/setup-msys2@v2 + with: + msystem: ucrt64 + install: mingw-w64-ucrt-x86_64-cc + - name: Run + run: | + $env:MSYS2_ROOT = msys2 -c 'cygpath -m /' + $env:PATH = "$env:PATH;$env:MSYS2_ROOT/ucrt64/bin" + tox + ci_setuptools: # Integration testing with setuptools strategy: diff --git a/distutils/tests/__init__.py b/distutils/tests/__init__.py index 93fbf490..cf8c1ed0 100644 --- a/distutils/tests/__init__.py +++ b/distutils/tests/__init__.py @@ -8,10 +8,12 @@ """ import shutil -from typing import Sequence +from typing import Sequence, Optional -def missing_compiler_executable(cmd_names: Sequence[str] = []): # pragma: no cover +def missing_compiler_executable( + cmd_names: Sequence[str] = [], compiler: Optional[str] = None +): # pragma: no cover """Check if the compiler components used to build the interpreter exist. Check for the existence of the compiler executables whose names are listed @@ -22,18 +24,18 @@ def missing_compiler_executable(cmd_names: Sequence[str] = []): # pragma: no co """ from distutils import ccompiler, errors, sysconfig - compiler = ccompiler.new_compiler() - sysconfig.customize_compiler(compiler) - if compiler.compiler_type == "msvc": + new_compiler = ccompiler.new_compiler(compiler=compiler) + sysconfig.customize_compiler(new_compiler) + if new_compiler.compiler_type == "msvc": # MSVC has no executables, so check whether initialization succeeds try: - compiler.initialize() + new_compiler.initialize() except errors.DistutilsPlatformError: return "msvc" - for name in compiler.executables: + for name in new_compiler.executables: if cmd_names and name not in cmd_names: continue - cmd = getattr(compiler, name) + cmd = getattr(new_compiler, name) if cmd_names: assert cmd is not None, f"the '{name}' executable is not configured" elif not cmd: diff --git a/distutils/tests/test_build_ext.py b/distutils/tests/test_build_ext.py index 6c4c4ba8..daf2717a 100644 --- a/distutils/tests/test_build_ext.py +++ b/distutils/tests/test_build_ext.py @@ -90,8 +90,14 @@ class TestBuildExt(TempdirManager): def build_ext(self, *args, **kwargs): return build_ext(*args, **kwargs) - def test_build_ext(self): - missing_compiler_executable() + @pytest.mark.parametrize( + 'compiler', + [None] + ['mingw32'] + if os.name == "nt" and missing_compiler_executable(compiler='mingw32') is None + else [], + ) + def test_build_ext(self, compiler): + missing_compiler_executable(compiler=compiler) copy_xxmodule_c(self.tmp_dir) xx_c = os.path.join(self.tmp_dir, 'xxmodule.c') xx_ext = Extension('xx', [xx_c]) @@ -101,6 +107,7 @@ def test_build_ext(self): fixup_build_ext(cmd) cmd.build_lib = self.tmp_dir cmd.build_temp = self.tmp_dir + cmd.compiler = compiler old_stdout = sys.stdout if not support.verbose: diff --git a/pytest.ini b/pytest.ini index dd57c6ef..5a80ddd0 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,7 +2,6 @@ norecursedirs=dist build .tox .eggs addopts= --doctest-modules - --import-mode importlib consider_namespace_packages=true filterwarnings= ## upstream