# HG changeset patch # User Matt Harbison # Date 1740417255 18000 # Node ID d333e14477f1effcfe4c2e1b2b17f64c7fe6572b # Parent 0e2be2abd963298c2b8521cd880642609f2f938c packaging: adapt `__version__.py` parsing for `setuptools_scm` output The file is now generated by `setuptools_scm`, which stores values as strings with strong quotes. This avoids the following failure at the end of the Inno installer build: creating installer Traceback (most recent call last): File "c:\Users\Matt\projects\mercurial\mercurial-devel\contrib\packaging\packaging.py", line 70, in run() File "c:\Users\Matt\projects\mercurial\mercurial-devel\contrib\packaging\packaging.py", line 62, in run cli.main() File "c:\Users\Matt\projects\mercurial\mercurial-devel\contrib\packaging\hgpackaging\cli.py", line 154, in main args.func(**kwargs) File "c:\Users\Matt\projects\mercurial\mercurial-devel\contrib\packaging\hgpackaging\cli.py", line 35, in build_inno inno.build_with_pyoxidizer( File "c:\Users\Matt\projects\mercurial\mercurial-devel\contrib\packaging\hgpackaging\inno.py", line 55, in build_with_pyoxidizer build_installer( File "c:\Users\Matt\projects\mercurial\mercurial-devel\contrib\packaging\hgpackaging\inno.py", line 146, in build_installer version = read_version_py(source_dir) File "c:\Users\Matt\projects\mercurial\mercurial-devel\contrib\packaging\hgpackaging\util.py", line 188, in read_version_py raise Exception('could not parse %s' % p) Exception: could not parse c:\Users\Matt\projects\mercurial\mercurial-devel\mercurial\__version__.py Note that non-tagged builds end up with complex version strings, and include characters that WiX rejects. That's probably fine- we don't do nightly or other non-tagged builds for installers. Also note that while the Inno installer is capable of using this version string as part of the installer, the WiX installer is not for some reason. That installer needs to be built with `--version VERSION` to inject the version into the installer metadata and the filename. diff -r 0e2be2abd963 -r d333e14477f1 contrib/packaging/hgpackaging/util.py --- a/contrib/packaging/hgpackaging/util.py Mon Feb 24 11:29:46 2025 -0500 +++ b/contrib/packaging/hgpackaging/util.py Mon Feb 24 12:14:15 2025 -0500 @@ -182,7 +182,7 @@ p = source_dir / 'mercurial' / '__version__.py' with p.open('r', encoding='utf-8') as fh: - m = re.search('version = b"([^"]+)"', fh.read(), re.MULTILINE) + m = re.search("version = '([^']+)'", fh.read(), re.MULTILINE) if not m: raise Exception('could not parse %s' % p)