Skip to content

Commit 58e4d3e

Browse files
committed
Bump setuptools to >=77.0.3
1 parent d764900 commit 58e4d3e

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

pyproject.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[build-system]
2-
# As of setuptools==74, we no longer need to
3-
# be concerned about distutils calling win32api
4-
# setuptools==76.1 breaks building of .mc files
5-
# win32/src/PythonService.cpp(49): fatal error C1083: Cannot open include file: 'PythonServiceMessages.h': No such file or directory
6-
requires = ["setuptools>=74,<76.1"]
2+
# setuptools==77.0.3 made PEP-639 license deprecations introduced by 77.0.0 into warnings rather than errors
3+
# setuptools==75.4 dropped support for Python 3.8
4+
requires = [
5+
"setuptools >=77.0.3; python_version >='3.9'",
6+
"setuptools <76.1; python_version <'3.9'",
7+
]
78
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
from collections.abc import MutableSequence
3737
from pathlib import Path
3838
from setuptools import Extension, setup
39+
from setuptools._distutils import ccompiler
3940
from setuptools.command.build import build
40-
from setuptools.command.build_ext import build_ext
4141
from setuptools.modified import newer_group
4242
from tempfile import gettempdir
4343
from typing import TYPE_CHECKING, Iterable
@@ -53,6 +53,22 @@
5353
from distutils._msvccompiler import MSVCCompiler
5454
from distutils.command.install_data import install_data
5555

56+
57+
def my_new_compiler(**kw):
58+
if "compiler" in kw and kw["compiler"] in (None, "msvc"):
59+
return my_compiler()
60+
return orig_new_compiler(**kw)
61+
62+
63+
# No way to cleanly wedge our compiler sub-class in.
64+
orig_new_compiler = ccompiler.new_compiler
65+
ccompiler.new_compiler = my_new_compiler # type: ignore[assignment] # Assuming the caller will always use only kwargs
66+
67+
68+
from setuptools.command.build_ext import (
69+
build_ext, # noqa: E402 # This has to be imported AFTER the compiler hack
70+
)
71+
5672
build_id_patch = build_id
5773
if not "." in build_id_patch:
5874
build_id_patch += ".0"
@@ -856,17 +872,6 @@ def swig_sources(self, sources, ext=None):
856872
return new_sources
857873

858874

859-
def my_new_compiler(**kw):
860-
if "compiler" in kw and kw["compiler"] in (None, "msvc"):
861-
return my_compiler()
862-
return orig_new_compiler(**kw)
863-
864-
865-
# No way to cleanly wedge our compiler sub-class in.
866-
orig_new_compiler = ccompiler.new_compiler
867-
ccompiler.new_compiler = my_new_compiler # type: ignore[assignment] # Assuming the caller will always use only kwargs
868-
869-
870875
class my_compiler(MSVCCompiler):
871876
def link(
872877
self,

0 commit comments

Comments
 (0)