Skip to content

Move verstamping to a better spot and reduce reliance on MSVCCompiler override hacks #2599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
62 changes: 18 additions & 44 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,24 @@ def build_extensions(self):
print("-- compiler.library_dirs:", self.compiler.library_dirs)
raise RuntimeError("Too many extensions skipped, check build environment")

for ext in [*self.extensions, *W32_exe_files]:
# Stamp the version of the built target.
# Do this externally to avoid suddenly dragging in the
# modules needed by this process, and which we will soon try and update.
ext_path = self.get_ext_fullpath(ext.name)
self.spawn(
[
sys.executable,
Path(__file__).parent / "win32" / "Lib" / "win32verstamp.py",
f"--version={pywin32_version}",
"--comments=https://github.com/mhammond/pywin32",
f"--original-filename={os.path.basename(ext_path)}",
"--product=PyWin32",
"--quiet" if "-v" not in sys.argv else "",
ext_path,
]
)

# Not sure how to make this completely generic, and there is no
# need at this stage.
self._build_scintilla()
Expand Down Expand Up @@ -868,50 +886,6 @@ def my_new_compiler(**kw):


class my_compiler(MSVCCompiler):
def link(
self,
target_desc,
objects,
output_filename,
output_dir=None,
libraries=None,
library_dirs=None,
runtime_library_dirs=None,
export_symbols=None,
debug=0,
*args,
**kw,
):
super().link(
target_desc,
objects,
output_filename,
output_dir,
libraries,
library_dirs,
runtime_library_dirs,
export_symbols,
debug,
*args,
**kw,
)
# Here seems a good place to stamp the version of the built
# target. Do this externally to avoid suddenly dragging in the
# modules needed by this process, and which we will soon try and
# update.
args = [
sys.executable,
# NOTE: On Python 3.7, all args must be str
str(Path(__file__).parent / "win32" / "Lib" / "win32verstamp.py"),
f"--version={pywin32_version}",
"--comments=https://github.com/mhammond/pywin32",
f"--original-filename={os.path.basename(output_filename)}",
"--product=PyWin32",
"--quiet" if "-v" not in sys.argv else "",
output_filename,
]
self.spawn(args)

# Work around bpo-36302/bpo-42009 - it sorts sources but this breaks
# support for building .mc files etc :(
def compile(self, sources, **kwargs):
Expand Down