Skip to content

Commit c0120da

Browse files
authored
Merge branch 'main' into multidim_safearray
2 parents b3ff561 + 18153a3 commit c0120da

File tree

3 files changed

+38
-28
lines changed

3 files changed

+38
-28
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ concurrency:
1212
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1313
cancel-in-progress: true
1414

15-
env:
16-
# We can't yet run tests with PYTHONDEVMODE=1, let's at least show warnings
17-
PYTHONWARNINGS: always
18-
1915
jobs:
2016
test:
2117
name: Build and test
@@ -26,6 +22,13 @@ jobs:
2622
matrix:
2723
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
2824
architecture: [x64, x86]
25+
env:
26+
# TODO: We can't yet run tests with PYTHONDEVMODE=1, let's emulated it as much as we can
27+
# https://docs.python.org/3/library/devmode.html#effects-of-the-python-development-mode
28+
PYTHONMALLOC: debug
29+
PYTHONASYNCIODEBUG: 1
30+
PYTHONWARNINGS: always
31+
# PYTHONFAULTHANDLER: 1 # This causes our tests to fail
2932

3033
steps:
3134
- uses: actions/checkout@v4

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Coming in build 312, as yet unreleased
1919
--------------------------------------
2020

2121
* Implement multidimensional SAFEARRAY(COM Record) and SAFEARRAY(double) (mhammond#2655, [@geppi][geppi])
22+
* Fixed missing version stamp on built `.dll` and `.exe` files (mhammond#2647, [@Avasam][Avasam])
2223
* Removed considerations for Windows 95/98/ME (mhammond#2400, [@Avasam][Avasam])
2324
This removes the following constants:
2425
* `win32con.FILE_ATTRIBUTE_ATOMIC_WRITE`

setup.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ def run(self):
378378

379379

380380
class my_build_ext(build_ext):
381-
def finalize_options(self):
382-
build_ext.finalize_options(self)
381+
def finalize_options(self) -> None:
382+
super().finalize_options()
383383

384384
self.plat_dir = {
385385
"win-amd64": "x64",
@@ -393,8 +393,9 @@ def finalize_options(self):
393393
if self.mingw32:
394394
self.libraries.append("stdc++")
395395

396-
self.excluded_extensions = [] # list of (ext, why)
397-
self.swig_cpp = True # hrm - deprecated - should use swig_opts=-c++??
396+
self.excluded_extensions: list[tuple[WinExt, str]] = []
397+
"""List of excluded extensions and their reason"""
398+
self.swig_opts.append("-c++")
398399

399400
def _why_cant_build_extension(self, ext):
400401
"""Return None, or a reason it can't be built."""
@@ -539,6 +540,25 @@ def _check_vc(self):
539540
print("-- ATLMFC paths likely missing (Required for win32ui)")
540541
return vcbase, vcverdir
541542

543+
def _verstamp(self, filename):
544+
"""
545+
Stamp the version of the built target.
546+
Do this externally to avoid suddenly dragging in the
547+
modules needed by this process.
548+
"""
549+
self.spawn(
550+
[
551+
sys.executable,
552+
Path(__file__).parent / "win32" / "Lib" / "win32verstamp.py",
553+
f"--version={pywin32_version}",
554+
"--comments=https://github.com/mhammond/pywin32",
555+
f"--original-filename={os.path.basename(filename)}",
556+
"--product=PyWin32",
557+
"--quiet" if "-v" not in sys.argv else "",
558+
filename,
559+
]
560+
)
561+
542562
def build_extensions(self):
543563
# First, sanity-check the 'extensions' list
544564
self.check_extensions_list(self.extensions)
@@ -598,24 +618,6 @@ def build_extensions(self):
598618
print("-- compiler.library_dirs:", self.compiler.library_dirs)
599619
raise RuntimeError("Too many extensions skipped, check build environment")
600620

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-
619621
# Not sure how to make this completely generic, and there is no
620622
# need at this stage.
621623
self._build_scintilla()
@@ -701,6 +703,8 @@ def build_exefile(self, ext):
701703
build_temp=self.build_temp,
702704
)
703705

706+
self._verstamp(full_name)
707+
704708
def build_extension(self, ext):
705709
# Some of these extensions are difficult to build, requiring various
706710
# hard-to-track libraries et (eg, exchange sdk, etc). So we
@@ -741,6 +745,7 @@ def build_extension(self, ext):
741745

742746
try:
743747
build_ext.build_extension(self, ext)
748+
self._verstamp(self.get_ext_fullpath(ext.name))
744749
# Convincing distutils to create .lib files with the name we
745750
# need is difficult, so we just hack around it by copying from
746751
# the created name to the name we need.
@@ -890,8 +895,9 @@ def swig_sources(self, sources, ext=None):
890895

891896

892897
class my_compiler(MSVCCompiler):
893-
# Work around bpo-36302/bpo-42009 - it sorts sources but this breaks
894-
# support for building .mc files etc :(
898+
# Work around python/cpython#80483 / python/cpython#86175
899+
# it sorts sources but this breaks support for building .mc files etc :(
900+
# See pypa/setuptools#4986 / pypa/distutils#370 for potential upstream fix.
895901
def compile(self, sources, **kwargs):
896902
# re-sort the list of source files but ensure all .mc files come first.
897903
def key_reverse_mc(a):

0 commit comments

Comments
 (0)