# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com
# Date 1650410512 14400
# Tue Apr 19 19:21:52 2022 -0400
# Node ID 83a3e09fce3708e3a6b128733d947bb75f8288aa
# Parent f0bd1f9455a29caa95f8458ac424e16c3382131e
# EXP-Topic windows-py3-packaging
packaging: stage the dependent repos when building the Windows installer
I really didn't want to replicate some of the current hierarchy of repos used to
build the installer, but there are various binary artifacts needed to build the
installer in various repos, and some of the `*.wxs` files have relative paths
that assume the directory structure. I don't want to change those until after
py2 support is dropped. With the recently added code to generate the `*.wxs`
files, some or most of these may go away anyway. But the build process is
complicated, and I'm sick of working on this enough that I'm settling for a
subset of the current build process for now.
None of the extensions other than hg-evolve that are currently bundled into the
py2 installer are cloned here. The keyring extension and other python
dependencies will be installed into the venv and bundled that way. The other
extensions aren't available on PyPI and haven't been ported to py3, so let's
simplify things and see if anyone complains.
One change here is to get rid of the clone of local clones, which I found
confusing. Instead, Mercurial is cloned right to `winbuild/build/hg` (so
there's only one copy), and the current thg code will be archived into place
when the installer is built (to pick up any local changes). Maybe Mercurial
should be cloned to the root of the dependencies directory and shared into
place to support other platforms, but that can be sorted out later.
The other important change here is that the staging is a separate step from the
(future) build command. The `winbuild` script had a tendency to update to
different branches, based on the target named on the command line, and a lot of
times that was a hassle. The current macOS scripts assume the repos are updated
as appropriate when run, and that has been more reliable.
diff --git a/.hgignore b/.hgignore
@@ -55,5 +55,6 @@
diff --git a/contrib/packaging/thgpackaging/cli.py b/contrib/packaging/thgpackaging/cli.py
@@ -12,6 +12,7 @@
from . import (
@@ -23,6 +24,7 @@
HERE = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))
SOURCE_DIR = HERE.parent.parent.parent
+SOURCE_DIRS = thgutil.SourceDirs(SOURCE_DIR)
def build_venv(python='', hg='', qt=None, output='', force=False, clean=False):
@@ -122,6 +124,70 @@
+ """Stage the other required repositories locally."""
+ if clean:
+ repos = [
+ for name, url, repo_dir, version in repos:
+ if repo_dir.exists():
+ print("Pulling %s" % name)
+ ["hg", "pull"],
+ print("Cloning %s" % name)
+ ["hg", "clone", "--noupdate", url, str(repo_dir)],
+ if version:
+ print("Updating %s to %s" % (name, version))
+ ["hg", "update", version],
parser = argparse.ArgumentParser()
@@ -193,6 +259,34 @@
+ sp = subparsers.add_parser(
+ "stage", help="Stage the projects bundled into the installer"
+ help=("The version of Mercurial to bundle. (default: 'stable')"),
+ help=("The version of evolve to bundle. (default: 'stable')"),
+ "The version of the shell extension to bundle. (default: 'default')"
+ help="Reclone the dependencies",
diff --git a/contrib/packaging/thgpackaging/util.py b/contrib/packaging/thgpackaging/util.py
@@ -22,6 +22,23 @@
+ def __init__(self, source_dir: pathlib.Path):
+ self._dependencies = source_dir / "dependencies"
+ self.original = source_dir
+ self.evolve = self._dependencies / "evolve"
+ self.winbuild = self._dependencies / "winbuild"
+ self.hg = self.winbuild / "build" / "hg"
+ self.shellext = self.winbuild / "build" / "shellext"
+ self.thg = self.winbuild / "build" / "thg"
+ def clean(self):
+ if self._dependencies.exists():
+ print("Deleting dependencies")
def extract_tar_to_directory(source: pathlib.Path, dest: pathlib.Path):
with tarfile.open(source, 'r') as tf: