Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing tests on Python 3.12 #225

Merged
merged 4 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ jobs:
needs:
- test
- collateral
- test_cygwin
# disabled due to disabled job
# - test_cygwin

runs-on: ubuntu-latest

Expand Down
32 changes: 32 additions & 0 deletions distutils/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,35 @@
distutils.command.tests package, since command identification is done
by import rather than matching pre-defined names.
"""

def missing_compiler_executable(cmd_names=[]): # 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
in 'cmd_names' or all the compiler executables when 'cmd_names' is empty
and return the first missing executable or None when none is found
missing.

"""
from distutils import ccompiler, sysconfig, spawn
from distutils import errors

compiler = ccompiler.new_compiler()
sysconfig.customize_compiler(compiler)
if compiler.compiler_type == "msvc":
# MSVC has no executables, so check whether initialization succeeds
try:
compiler.initialize()
except errors.PlatformError:
return "msvc"
for name in compiler.executables:
if cmd_names and name not in cmd_names:
continue
cmd = getattr(compiler, name)
if cmd_names:
assert cmd is not None, \
"the '%s' executable is not configured" % name
elif not cmd:
continue
if spawn.find_executable(cmd[0]) is None:
return cmd[0]
4 changes: 1 addition & 3 deletions distutils/tests/test_build_clib.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""Tests for distutils.command.build_clib."""
import os

from test.support import missing_compiler_executable

import pytest

from distutils.command.build_clib import build_clib
from distutils.errors import DistutilsSetupError
from distutils.tests import support
from distutils.tests import support, missing_compiler_executable


class TestBuildCLib(support.TempdirManager):
Expand Down
5 changes: 3 additions & 2 deletions distutils/tests/test_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from distutils.core import Distribution
from distutils.command.build_ext import build_ext
from distutils import sysconfig
from distutils.tests import missing_compiler_executable
from distutils.tests.support import (
TempdirManager,
copy_xxmodule_c,
Expand Down Expand Up @@ -89,7 +90,7 @@ def build_ext(self, *args, **kwargs):
return build_ext(*args, **kwargs)

def test_build_ext(self):
cmd = support.missing_compiler_executable()
missing_compiler_executable()
copy_xxmodule_c(self.tmp_dir)
xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
xx_ext = Extension('xx', [xx_c])
Expand Down Expand Up @@ -359,7 +360,7 @@ def test_compiler_option(self):
assert cmd.compiler == 'unix'

def test_get_outputs(self):
cmd = support.missing_compiler_executable()
missing_compiler_executable()
tmp_dir = self.mkdtemp()
c_file = os.path.join(tmp_dir, 'foo.c')
self.write_file(c_file, 'void PyInit_foo(void) {}\n')
Expand Down
3 changes: 1 addition & 2 deletions distutils/tests/test_config_cmd.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Tests for distutils.command.config."""
import os
import sys
from test.support import missing_compiler_executable

import pytest

from distutils.command.config import dump_file, config
from distutils.tests import support
from distutils.tests import support, missing_compiler_executable
from distutils._log import log


Expand Down
5 changes: 2 additions & 3 deletions distutils/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
from distutils.errors import DistutilsOptionError
from distutils.extension import Extension

from distutils.tests import support
from test import support as test_support
from distutils.tests import support, missing_compiler_executable


def _make_ext_name(modname):
Expand Down Expand Up @@ -213,7 +212,7 @@ def test_record(self):
assert found == expected

def test_record_extensions(self):
cmd = test_support.missing_compiler_executable()
cmd = missing_compiler_executable()
if cmd is not None:
pytest.skip('The %r command is not found' % cmd)
install_dir = self.mkdtemp()
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ install_requires =

[options.packages.find]
exclude =
build*
dist*
docs*
tests*

Expand Down