|
35 | 35 | import winreg |
36 | 36 | from collections.abc import MutableSequence |
37 | 37 | from pathlib import Path |
| 38 | +from tempfile import gettempdir |
| 39 | +from typing import TYPE_CHECKING, Iterable |
| 40 | + |
38 | 41 | from setuptools import Extension, setup |
39 | 42 | from setuptools.command.build import build |
40 | | -from setuptools.command.build_ext import build_ext |
41 | 43 | from setuptools.modified import newer_group |
42 | | -from tempfile import gettempdir |
43 | | -from typing import TYPE_CHECKING, Iterable |
| 44 | +from setuptools._distutils import ccompiler |
44 | 45 |
|
45 | 46 | # We must import from distutils directly at runtime |
46 | 47 | # But this prevents typing issues across Python 3.11-3.12 |
|
53 | 54 | from distutils._msvccompiler import MSVCCompiler |
54 | 55 | from distutils.command.install_data import install_data |
55 | 56 |
|
| 57 | + |
| 58 | +def my_new_compiler(**kw): |
| 59 | + raise Exception("Is this ever called?") |
| 60 | + if "compiler" in kw and kw["compiler"] in (None, "msvc"): |
| 61 | + return my_compiler() |
| 62 | + return orig_new_compiler(**kw) |
| 63 | + |
| 64 | + |
| 65 | +# No way to cleanly wedge our compiler sub-class in. |
| 66 | +orig_new_compiler = ccompiler.new_compiler |
| 67 | +ccompiler.new_compiler = my_new_compiler # type: ignore[assignment] # Assuming the caller will always use only kwargs |
| 68 | + |
| 69 | + |
| 70 | +from setuptools.command.build_ext import build_ext # noqa: E402 # This has to be imported AFTER the compiler hack |
| 71 | + |
| 72 | + |
56 | 73 | build_id_patch = build_id |
57 | | -if not "." in build_id_patch: |
| 74 | +if "." not in build_id_patch: |
58 | 75 | build_id_patch += ".0" |
59 | 76 | pywin32_version = "%d.%d.%s" % ( |
60 | 77 | sys.version_info.major, |
@@ -310,7 +327,7 @@ def __init__(self, name, **kw): |
310 | 327 |
|
311 | 328 | # The stand-alone exchange SDK has these libs |
312 | 329 | # Additional utility functions are only available for 32-bit builds. |
313 | | - if not platform.machine() in ("AMD64", "ARM64"): |
| 330 | + if platform.machine() not in ("AMD64", "ARM64"): |
314 | 331 | libs += " version user32 advapi32 Ex2KSdk sadapi netapi32" |
315 | 332 | kw["libraries"] = libs |
316 | 333 | WinExt_win32com.__init__(self, name, **kw) |
@@ -856,17 +873,6 @@ def swig_sources(self, sources, ext=None): |
856 | 873 | return new_sources |
857 | 874 |
|
858 | 875 |
|
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 | | - |
870 | 876 | class my_compiler(MSVCCompiler): |
871 | 877 | def link( |
872 | 878 | self, |
@@ -922,6 +928,7 @@ def key_reverse_mc(a): |
922 | 928 | return (e, b) |
923 | 929 |
|
924 | 930 | sources = sorted(sources, key=key_reverse_mc) |
| 931 | + raise Exception("breakpoint") |
925 | 932 | return MSVCCompiler.compile(self, sources, **kwargs) |
926 | 933 |
|
927 | 934 | def spawn(self, cmd: MutableSequence[str]) -> None: # type: ignore[override] # More restrictive than supertype |
|
0 commit comments