Skip to content

Commit 26163c9

Browse files
committed
[dist] Omit trailing suffixes on artifacts to match existing convention
1 parent 38d6a9e commit 26163c9

5 files changed

Lines changed: 41 additions & 51 deletions

File tree

scripts/_release_common.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,26 @@
2323

2424

2525
def msi_version(raw: str) -> str:
26-
# Mirror scripts/update_installer.py - artifact filenames use the
27-
# normalized X.Y.Z form, not the raw Python __version__.
26+
# AdvancedInstaller's MSI ProductVersion field requires numeric X.Y.Z[.B];
27+
# strip Python-style suffixes ("0.7-dev0" -> "0.7") and pad to three parts.
28+
# Use this ONLY for the /SetVersion value passed to AdvancedInstaller, not
29+
# for artifact filenames - those should use display_version() to match the
30+
# Python package version (e.g. PyPI "0.7", not "0.7.0").
2831
parts = [re.split(r"[^\d]", p, maxsplit=1)[0] for p in raw.split(".")]
2932
while len(parts) < 3:
3033
parts.append("0")
3134
return ".".join(parts[:4])
3235

3336

37+
def display_version(raw: str) -> str:
38+
# Filename-facing version: matches scenedetect.__version__ component count,
39+
# with Python-style suffixes stripped ("0.7-dev0" -> "0.7", "0.7" -> "0.7",
40+
# "0.7.1" -> "0.7.1"). Use for .msi/.zip/manifest filenames so artifacts
41+
# line up with the PyPI package and git tag.
42+
parts = [re.split(r"[^\d]", p, maxsplit=1)[0] for p in raw.split(".")]
43+
return ".".join(p for p in parts[:4] if p)
44+
45+
3446
def find_7zip() -> Path:
3547
for candidate in (
3648
Path(r"C:\Program Files\7-Zip\7z.exe"),

scripts/finalize_windows_dist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@
4444

4545
import validate_release # noqa: E402
4646
from _release_common import ( # noqa: E402
47+
display_version,
4748
find_7zip,
4849
hash_zip_contents,
49-
msi_version,
5050
sha256_file,
5151
verify_authenticode,
5252
)
5353

5454
import scenedetect # noqa: E402
5555

56-
VERSION = msi_version(scenedetect.__version__)
56+
VERSION = display_version(scenedetect.__version__)
5757

5858

5959
def extract_signed_bundle(signed_zip: Path, dest: Path) -> tuple[Path, Path]:

scripts/stage_windows_dist.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
# into a combined "prepare_windows_dist.py".
3434

3535
import argparse
36-
import re
3736
import shutil
3837
import subprocess
3938
import sys
@@ -46,6 +45,9 @@
4645

4746
REPO_DIR = Path(__file__).resolve().parent.parent
4847
sys.path.insert(0, str(REPO_DIR))
48+
sys.path.insert(0, str(Path(__file__).resolve().parent))
49+
50+
from _release_common import display_version, find_7zip # noqa: E402
4951

5052
import scenedetect # noqa: E402
5153

@@ -56,23 +58,6 @@
5658
THIRDPARTY_LICENSES = REPO_DIR / "scenedetect" / "_thirdparty"
5759

5860

59-
def msi_version(raw: str) -> str:
60-
parts = [re.split(r"[^\d]", p, maxsplit=1)[0] for p in raw.split(".")]
61-
while len(parts) < 3:
62-
parts.append("0")
63-
return ".".join(parts[:4])
64-
65-
66-
def find_7zip() -> Path:
67-
for candidate in (
68-
Path(r"C:\Program Files\7-Zip\7z.exe"),
69-
Path(r"C:\Program Files (x86)\7-Zip\7z.exe"),
70-
):
71-
if candidate.exists():
72-
return candidate
73-
sys.exit("7-Zip not found. Install from https://www.7-zip.org/.")
74-
75-
7661
def _rel(p: Path) -> str:
7762
# Display paths relative to the repo when possible, else fall back to the
7863
# absolute path (e.g. --ffmpeg-dir pointing outside the repo on CI).
@@ -190,7 +175,7 @@ def main() -> None:
190175
copy_file(PACKAGING_WIN / "README.txt", DIST_TREE / "README.txt")
191176
stage_thirdparty_licenses()
192177
build_docs()
193-
make_portable_zip(msi_version(scenedetect.__version__))
178+
make_portable_zip(display_version(scenedetect.__version__))
194179

195180

196181
if __name__ == "__main__":

scripts/update_installer.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,22 @@
2121

2222
import argparse
2323
import os
24-
import re
2524
import subprocess
2625
import sys
2726
from pathlib import Path
2827

2928
REPO_DIR = Path(__file__).resolve().parent.parent
3029
sys.path.insert(0, str(REPO_DIR))
30+
sys.path.insert(0, str(Path(__file__).resolve().parent))
31+
32+
from _release_common import display_version, msi_version # noqa: E402
3133

3234
import scenedetect # noqa: E402
3335

3436
INSTALLER_AIP = REPO_DIR / "packaging" / "windows" / "installer" / "PySceneDetect.aip"
3537
DIST_TREE = REPO_DIR / "dist" / "scenedetect"
3638

3739

38-
def msi_version(raw: str) -> str:
39-
# AdvancedInstaller's ProductVersion only accepts numeric X[.Y[.Z[.B]]].
40-
# Strip Python-style suffixes ("0.7-dev0" -> "0.7"; "1.0.0-rc1" -> "1.0.0")
41-
# and pad to three components so the resulting MSI filename is consistent.
42-
parts = [re.split(r"[^\d]", p, maxsplit=1)[0] for p in raw.split(".")]
43-
if not all(p.isdigit() for p in parts if p):
44-
sys.exit(f"Cannot derive numeric MSI version from {raw!r}")
45-
while len(parts) < 3:
46-
parts.append("0")
47-
return ".".join(parts[:4])
48-
49-
5040
def find_advinst() -> Path:
5141
if env := os.environ.get("ADVINST"):
5242
path = Path(env)
@@ -122,24 +112,28 @@ def main() -> None:
122112
print(f"Re-syncing APPDIR in {INSTALLER_AIP.name}")
123113
resync_appdir(advinst)
124114
if args.dev:
125-
version = msi_version(args.version_override or scenedetect.__version__)
126-
dev_name = f"PySceneDetect-{version}-dev-win64.msi"
115+
raw_version = args.version_override or scenedetect.__version__
116+
file_version = display_version(raw_version)
117+
dev_name = f"PySceneDetect-{file_version}-dev-win64.msi"
127118
print(f"Renaming MSI package to {dev_name} (dev build)")
128119
run(advinst, "/SetPackageName", dev_name, "-buildname", "DefaultBuild")
129120
return
130121

131122
raw_version = args.version_override or scenedetect.__version__
132-
version = msi_version(raw_version)
133-
if version != raw_version:
134-
print(f"Normalized {raw_version!r} -> {version!r} for AdvancedInstaller")
135-
print(f"Bumping {INSTALLER_AIP.name} to {version}")
136-
137-
run(advinst, "/SetVersion", version)
123+
product_version = msi_version(raw_version)
124+
file_version = display_version(raw_version)
125+
if not all(p.isdigit() for p in product_version.split(".") if p):
126+
sys.exit(f"Cannot derive numeric MSI version from {raw_version!r}")
127+
if product_version != raw_version:
128+
print(f"Normalized {raw_version!r} -> {product_version!r} for AdvancedInstaller")
129+
print(f"Bumping {INSTALLER_AIP.name} to {product_version} (filename: {file_version})")
130+
131+
run(advinst, "/SetVersion", product_version)
138132
run(advinst, "/SetProductCode", "-langid", "1033")
139133
run(
140134
advinst,
141135
"/SetPackageName",
142-
f"PySceneDetect-{version}-win64.msi",
136+
f"PySceneDetect-{file_version}-win64.msi",
143137
"-buildname",
144138
"DefaultBuild",
145139
)

scripts/validate_release.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@
4848
sys.path.insert(0, str(Path(__file__).resolve().parent))
4949

5050
from _release_common import ( # noqa: E402
51+
display_version,
5152
find_7zip,
5253
hash_zip_contents,
53-
msi_version,
5454
sha256_file,
5555
verify_authenticode,
5656
)
5757

5858
import scenedetect # noqa: E402
5959

60-
VERSION = msi_version(scenedetect.__version__)
60+
VERSION = display_version(scenedetect.__version__)
6161

6262
# Mirrors `third_party_packages` in `scenedetect/platform.py:get_system_version_info()`.
6363
# Keep these two lists in sync: any package added there should be classified here as
@@ -313,10 +313,9 @@ def check_frozen_exe(portable_zip: Path) -> None:
313313
fail(f"`scenedetect.exe version` exited {result.returncode}\n{result.stderr}")
314314
packages = _parse_packages_section(result.stdout)
315315
scenedetect_reported = packages.get("scenedetect", "")
316-
# Normalize both sides through msi_version() so a raw __version__ of "0.7"
317-
# matches the artifact-name VERSION of "0.7.0" (mirrors the same
318-
# normalization scripts/update_installer.py applies to filenames).
319-
if msi_version(scenedetect_reported) != VERSION:
316+
# Normalize both sides through display_version() so a raw __version__
317+
# like "0.7-dev0" matches the artifact-name VERSION of "0.7".
318+
if display_version(scenedetect_reported) != VERSION:
320319
fail(
321320
f"`scenedetect.exe version` reports scenedetect=={scenedetect_reported!r}, "
322321
f"expected {VERSION!r} (raw __version__ normalized)"

0 commit comments

Comments
 (0)