Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lazka committed Jul 21, 2024
1 parent cf47197 commit 582c2ea
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 10 additions & 8 deletions distutils/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
11 changes: 9 additions & 2 deletions distutils/tests/test_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
norecursedirs=dist build .tox .eggs
addopts=
--doctest-modules
--import-mode importlib
consider_namespace_packages=true
filterwarnings=
## upstream
Expand Down

0 comments on commit 582c2ea

Please sign in to comment.