fix: do not overwrite __version__ (#1170)

This commit is contained in:
Moritz
2022-09-14 22:45:58 +02:00
committed by GitHub
parent 36e304839b
commit b1b15e2eef
2 changed files with 1 additions and 25 deletions

View File

@@ -6,31 +6,6 @@ import subprocess
import wcwidth
# git output will look like:
#
# tags/v1.0.0-0-g3af38dc
# ------- tag
# - commits since
# g------- git hash fragment
version = (
subprocess.check_output(["git", "describe", "--always", "--tags", "--long"])
.decode("utf-8")
.strip()
.replace("tags/", "")
)
# when invoking pyinstaller from the project root, this gets run from the project root.
with open("./capa/version.py", "r", encoding="utf-8") as f:
lines = f.read()
# version.py contains the version string and other helper functions
# here we manually replace the version value substring with the result of the above git output
VERSION_DEF = "__version__ = "
s = lines.index(VERSION_DEF)
e = s + len(VERSION_DEF)
off_rest_file = e + lines[e:].index("\n")
lines = lines[s:e] + f'"{version}"' + lines[off_rest_file:]
with open("./capa/version.py", "w", encoding="utf-8") as f:
f.write(lines)
a = Analysis(
# when invoking pyinstaller from the project root,
# this gets invoked from the directory of the spec file,

View File

@@ -20,6 +20,7 @@
### Bug Fixes
- render: convert feature attributes to aliased dictionary for vverbose #1152 @mike-hunhoff
- decouple Token dependency / extractor and features #1139 @mr-tz
- do not overwrite version in version.py during PyInstaller build #1169 @mr-tz
### capa explorer IDA Pro plugin
- fix: display instruction items #1154 @mr-tz