diff --git a/pyproject.toml b/pyproject.toml index 101d70261f..ad9c1daed2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,8 @@ [build-system] -# As of setuptools==74, we no longer need to -# be concerned about distutils calling win32api -# setuptools==76.1 breaks building of .mc files -# win32/src/PythonService.cpp(49): fatal error C1083: Cannot open include file: 'PythonServiceMessages.h': No such file or directory -requires = ["setuptools>=74,<76.1"] +# setuptools==77.0.3 made PEP-639 license deprecations introduced by 77.0.0 into warnings rather than errors +# setuptools==75.4 dropped support for Python 3.8 +requires = [ + "setuptools >=77.0.3; python_version >='3.9'", + "setuptools <76.1; python_version <'3.9'", +] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index 4b4c73d3be..e59f0b61c9 100644 --- a/setup.py +++ b/setup.py @@ -36,8 +36,8 @@ from collections.abc import MutableSequence from pathlib import Path from setuptools import Extension, setup +from setuptools._distutils import ccompiler from setuptools.command.build import build -from setuptools.command.build_ext import build_ext from setuptools.modified import newer_group from tempfile import gettempdir from typing import TYPE_CHECKING, Iterable @@ -53,6 +53,21 @@ from distutils._msvccompiler import MSVCCompiler from distutils.command.install_data import install_data + +def my_new_compiler(**kw): + if "compiler" in kw and kw["compiler"] in (None, "msvc"): + return my_compiler() + return orig_new_compiler(**kw) + + +# No way to cleanly wedge our compiler sub-class in. +orig_new_compiler = ccompiler.new_compiler +ccompiler.new_compiler = my_new_compiler # type: ignore[assignment] # Assuming the caller will always use only kwargs + + +# This import has to be delayed to AFTER the compiler hack +from setuptools.command.build_ext import build_ext # noqa: E402 + build_id_patch = build_id if not "." in build_id_patch: build_id_patch += ".0" @@ -856,17 +871,6 @@ def swig_sources(self, sources, ext=None): return new_sources -def my_new_compiler(**kw): - if "compiler" in kw and kw["compiler"] in (None, "msvc"): - return my_compiler() - return orig_new_compiler(**kw) - - -# No way to cleanly wedge our compiler sub-class in. -orig_new_compiler = ccompiler.new_compiler -ccompiler.new_compiler = my_new_compiler # type: ignore[assignment] # Assuming the caller will always use only kwargs - - class my_compiler(MSVCCompiler): def link( self,