Skip to content

Commit

Permalink
Tweak how the binaries are version stamped
Browse files Browse the repository at this point in the history
  • Loading branch information
mhammond committed Jun 13, 2020
1 parent 6028583 commit 45c4414
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@
build_id_patch)
print("Building pywin32", pywin32_version)

try:
sys.argv.remove("--skip-verstamp")
skip_verstamp = True
except ValueError:
skip_verstamp = False

try:
this_file = __file__
except NameError:
Expand Down Expand Up @@ -1455,36 +1461,25 @@ def link(self,
# target. Do this externally to avoid suddenly dragging in the
# modules needed by this process, and which we will soon try and
# update.
try:
ok = True
except ImportError:
ok = False
if ok:
stamp_script = os.path.join(sys.prefix,
"Lib",
"site-packages",
"win32",
"lib",
"win32verstamp.py",
)
ok = os.path.isfile(stamp_script)
if ok:
args = [sys.executable]
args.append(stamp_script)
# Further, we don't really want to use sys.executable, because that
# means the build environment must have a current pywin32 installed
# in every version, which is a bit of a burden only for this.
# So we assume the "default" Python version (ie, the version run by
# py.exe) has pywin32 installed.
# (This creates a chicken-and-egg problem though! We used to work around
# this by ignoring failure to verstamp, but that's easy to miss. So now
# allow --skip-verstamp on the cmdline - but if it's not there, the
# verstamp must work.)
if not skip_verstamp:
args = ["py.exe", "-m" "win32verstamp"]
args.append("--version=%s" % (pywin32_version,))
args.append("--comments=https://github.com/mhammond/pywin32")
args.append("--original-filename=%s" % (os.path.basename(output_filename),))
args.append("--product=PyWin32")
if '-v' not in sys.argv:
args.append("--quiet")
args.append(output_filename)
try:
self.spawn(args)
except DistutilsExecError as msg:
log.info("VersionStamp failed: %s", msg)
ok = False
if not ok:
log.info('Unable to import verstamp, no version info will be added')
self.spawn(args)


################################################################
Expand Down

0 comments on commit 45c4414

Please sign in to comment.