Skip to content
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
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
28 changes: 16 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand Down