kopia lustrzana https://github.com/corrscope/corrscope
[appveyor] Append version number to .zip artifacts
rodzic
bd996137c7
commit
7ffa0ba22b
|
@ -56,4 +56,3 @@ after_test:
|
|||
|
||||
artifacts:
|
||||
- path: 'dist\*'
|
||||
- path: 'dist\corrscope'
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import glob
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
from PyInstaller.building.api import PYZ, EXE, COLLECT
|
||||
from PyInstaller.building.build_main import Analysis
|
||||
from PyInstaller.building.datastruct import TOC
|
||||
|
||||
from corrscope import version
|
||||
from corrscope import version as v
|
||||
|
||||
|
||||
block_cipher = None
|
||||
|
@ -18,8 +20,11 @@ def keep(dir, wildcard):
|
|||
|
||||
datas = keep("corrscope/gui", "*.ui") + keep("corrscope/path", "*")
|
||||
|
||||
version.pyinstaller_write_version()
|
||||
datas.append((version.version_txt, "."))
|
||||
version = v.pyinstaller_write_version()
|
||||
datas.append((v.version_txt, "."))
|
||||
|
||||
app_name = "corrscope"
|
||||
app_name_version = f"{app_name}-{version}"
|
||||
|
||||
a = Analysis(
|
||||
["corrscope/__main__.py"],
|
||||
|
@ -38,7 +43,7 @@ a = Analysis(
|
|||
|
||||
|
||||
# Some dirs are included by PyInstaller hooks and must be removed after the fact.
|
||||
path_excludes = (
|
||||
_path_excludes = (
|
||||
# Matplotlib
|
||||
"""
|
||||
mpl-data/fonts
|
||||
|
@ -59,7 +64,7 @@ path_excludes = (
|
|||
libEGL.dll libGLESv2.dll d3dcompiler_ opengl32sw.dll
|
||||
"""
|
||||
).split()
|
||||
path_excludes = {s.lower() for s in path_excludes}
|
||||
path_excludes = {s.lower() for s in _path_excludes}
|
||||
|
||||
|
||||
def path_contains(path: str) -> bool:
|
||||
|
@ -89,13 +94,27 @@ exe = EXE(
|
|||
a.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name="corrscope",
|
||||
name=app_name,
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
console=True,
|
||||
)
|
||||
coll = COLLECT(
|
||||
exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=True, name="corrscope"
|
||||
|
||||
class ZipCollect(COLLECT):
|
||||
name: str # absolute-ish path, != __init__(name=)
|
||||
|
||||
def assemble(self):
|
||||
ret = super().assemble()
|
||||
|
||||
new_name = str(Path(self.name).with_name(app_name_version))
|
||||
with zipfile.ZipFile(new_name + '.zip', 'w', zipfile.ZIP_DEFLATED) as z:
|
||||
z.write(self.name)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
coll = ZipCollect(
|
||||
exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=True, name=app_name
|
||||
)
|
||||
|
|
|
@ -40,19 +40,24 @@ def get_version() -> str:
|
|||
return base_version
|
||||
|
||||
|
||||
def pyinstaller_write_version():
|
||||
""" Called only at pyinstaller time.
|
||||
def pyinstaller_write_version() -> str:
|
||||
""" Returns version.
|
||||
|
||||
Called only at pyinstaller time.
|
||||
Writes to filesystem, does NOT call get_version().
|
||||
Filesystem is ignored if version number isn't prerelease (x.y.z-pre).
|
||||
"""
|
||||
build_metadata = _calc_metadata()
|
||||
version = _base_plus_metadata(build_metadata)
|
||||
|
||||
with version_txt.open("w") as txt:
|
||||
txt.write(_base_plus_metadata(build_metadata))
|
||||
txt.write(version)
|
||||
|
||||
with version_py.open("w") as f:
|
||||
f.write(f"{metadata_key} = {repr(build_metadata)}")
|
||||
|
||||
return version
|
||||
|
||||
|
||||
# Compute version suffix
|
||||
env = {}
|
||||
|
|
Ładowanie…
Reference in New Issue