Comments
Patch
@@ -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
@@ -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)
@@ -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'))