|
36 | 36 | from collections.abc import MutableSequence |
37 | 37 | from pathlib import Path |
38 | 38 | from setuptools import Extension, setup |
| 39 | +from setuptools._distutils import ccompiler |
39 | 40 | from setuptools.command.build import build |
40 | | -from setuptools.command.build_ext import build_ext |
41 | 41 | from setuptools.modified import newer_group |
42 | 42 | from tempfile import gettempdir |
43 | 43 | from typing import TYPE_CHECKING, Iterable |
|
53 | 53 | from distutils._msvccompiler import MSVCCompiler |
54 | 54 | from distutils.command.install_data import install_data |
55 | 55 |
|
| 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 | +# This import has to be delayed to AFTER the compiler hack |
| 69 | +from setuptools.command.build_ext import build_ext # noqa: E402 |
| 70 | + |
56 | 71 | build_id_patch = build_id |
57 | 72 | if not "." in build_id_patch: |
58 | 73 | build_id_patch += ".0" |
@@ -583,6 +598,24 @@ def build_extensions(self): |
583 | 598 | print("-- compiler.library_dirs:", self.compiler.library_dirs) |
584 | 599 | raise RuntimeError("Too many extensions skipped, check build environment") |
585 | 600 |
|
| 601 | + for ext in [*self.extensions, *W32_exe_files]: |
| 602 | + # Stamp the version of the built target. |
| 603 | + # Do this externally to avoid suddenly dragging in the |
| 604 | + # modules needed by this process, and which we will soon try and update. |
| 605 | + ext_path = self.get_ext_fullpath(ext.name) |
| 606 | + self.spawn( |
| 607 | + [ |
| 608 | + sys.executable, |
| 609 | + Path(__file__).parent / "win32" / "Lib" / "win32verstamp.py", |
| 610 | + f"--version={pywin32_version}", |
| 611 | + "--comments=https://github.com/mhammond/pywin32", |
| 612 | + f"--original-filename={os.path.basename(ext_path)}", |
| 613 | + "--product=PyWin32", |
| 614 | + "--quiet" if "-v" not in sys.argv else "", |
| 615 | + ext_path, |
| 616 | + ] |
| 617 | + ) |
| 618 | + |
586 | 619 | # Not sure how to make this completely generic, and there is no |
587 | 620 | # need at this stage. |
588 | 621 | self._build_scintilla() |
@@ -856,62 +889,7 @@ def swig_sources(self, sources, ext=None): |
856 | 889 | return new_sources |
857 | 890 |
|
858 | 891 |
|
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 | 892 | class my_compiler(MSVCCompiler): |
871 | | - def link( |
872 | | - self, |
873 | | - target_desc, |
874 | | - objects, |
875 | | - output_filename, |
876 | | - output_dir=None, |
877 | | - libraries=None, |
878 | | - library_dirs=None, |
879 | | - runtime_library_dirs=None, |
880 | | - export_symbols=None, |
881 | | - debug=0, |
882 | | - *args, |
883 | | - **kw, |
884 | | - ): |
885 | | - super().link( |
886 | | - target_desc, |
887 | | - objects, |
888 | | - output_filename, |
889 | | - output_dir, |
890 | | - libraries, |
891 | | - library_dirs, |
892 | | - runtime_library_dirs, |
893 | | - export_symbols, |
894 | | - debug, |
895 | | - *args, |
896 | | - **kw, |
897 | | - ) |
898 | | - # Here seems a good place to stamp the version of the built |
899 | | - # target. Do this externally to avoid suddenly dragging in the |
900 | | - # modules needed by this process, and which we will soon try and |
901 | | - # update. |
902 | | - args = [ |
903 | | - sys.executable, |
904 | | - # NOTE: On Python 3.7, all args must be str |
905 | | - str(Path(__file__).parent / "win32" / "Lib" / "win32verstamp.py"), |
906 | | - f"--version={pywin32_version}", |
907 | | - "--comments=https://github.com/mhammond/pywin32", |
908 | | - f"--original-filename={os.path.basename(output_filename)}", |
909 | | - "--product=PyWin32", |
910 | | - "--quiet" if "-v" not in sys.argv else "", |
911 | | - output_filename, |
912 | | - ] |
913 | | - self.spawn(args) |
914 | | - |
915 | 893 | # Work around bpo-36302/bpo-42009 - it sorts sources but this breaks |
916 | 894 | # support for building .mc files etc :( |
917 | 895 | def compile(self, sources, **kwargs): |
@@ -2030,6 +2008,7 @@ def convert_optional_data_files(files): |
2030 | 2008 | "Programming Language :: Python :: 3.11", |
2031 | 2009 | "Programming Language :: Python :: 3.12", |
2032 | 2010 | "Programming Language :: Python :: 3.13", |
| 2011 | + "Programming Language :: Python :: 3.14", |
2033 | 2012 | "Programming Language :: Python :: Implementation :: CPython", |
2034 | 2013 | ] |
2035 | 2014 |
|
|
0 commit comments