Mercurial > hg
changeset 43518:7c9f63a5cb14
packaging: always pass VERSION into Inno invocation
The code in the Inno file was a holdover from before we had
Python driving execution.
With Python in the driver's seat, we can now have it resolve
the version string and pass it into Inno, making the code
easier to understand for people who aren't packaging gurus.
Differential Revision: https://phab.mercurial-scm.org/D7161
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 22 Oct 2019 18:34:03 -0700 |
parents | 24633444ff32 |
children | 2aaf245639bf |
files | contrib/packaging/hgpackaging/inno.py contrib/packaging/hgpackaging/util.py contrib/packaging/inno/mercurial.iss |
diffstat | 3 files changed, 22 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/packaging/hgpackaging/inno.py Thu Oct 24 21:22:08 2019 -0700 +++ b/contrib/packaging/hgpackaging/inno.py Tue Oct 22 18:34:03 2019 -0700 @@ -18,7 +18,10 @@ build_py2exe, stage_install, ) -from .util import find_vc_runtime_files +from .util import ( + find_vc_runtime_files, + read_version_py, +) EXTRA_PACKAGES = { 'dulwich', @@ -149,8 +152,10 @@ if vc_x64: args.append('/dARCH=x64') - if version: - args.append('/dVERSION=%s' % version) + if not version: + version = read_version_py(source_dir) + + args.append('/dVERSION=%s' % version) args.append('/Odist') args.append(str(inno_build_dir / 'mercurial.iss'))
--- a/contrib/packaging/hgpackaging/util.py Thu Oct 24 21:22:08 2019 -0700 +++ b/contrib/packaging/hgpackaging/util.py Tue Oct 22 18:34:03 2019 -0700 @@ -12,6 +12,7 @@ import glob import os import pathlib +import re import shutil import subprocess import tarfile @@ -210,3 +211,16 @@ full_dest_path.parent.mkdir(parents=True, exist_ok=True) shutil.copy(full_source_path, full_dest_path) print('copying %s to %s' % (full_source_path, full_dest_path)) + + +def read_version_py(source_dir): + """Read the mercurial/__version__.py file to resolve the version string.""" + p = source_dir / 'mercurial' / '__version__.py' + + with p.open('r', encoding='utf-8') as fh: + m = re.search('version = b"([^"]+)"', fh.read(), re.MULTILINE) + + if not m: + raise Exception('could not parse %s' % p) + + return m.group(1)
--- a/contrib/packaging/inno/mercurial.iss Thu Oct 24 21:22:08 2019 -0700 +++ b/contrib/packaging/inno/mercurial.iss Tue Oct 22 18:34:03 2019 -0700 @@ -1,21 +1,6 @@ ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! -#ifndef VERSION -#define FileHandle -#define FileLine -#define VERSION = "unknown" -#if FileHandle = FileOpen(SourcePath + "\..\..\mercurial\__version__.py") - #expr FileLine = FileRead(FileHandle) - #expr FileLine = FileRead(FileHandle) - #define VERSION = Copy(FileLine, Pos('"', FileLine)+1, Len(FileLine)-Pos('"', FileLine)-1) -#endif -#if FileHandle - #expr FileClose(FileHandle) -#endif -#pragma message "Detected Version: " + VERSION -#endif - #ifndef ARCH #define ARCH = "x86" #endif