changeset 47209:d09b36f69180

packaging: extract invocation of pyoxidizer to own function I'll be refactoring how the WiX installer creation calls into pyoxidizer and will need a lower level function for facilitating that. The new `run_pyoxidizer()` builds our execution environment (with gettext available) and invokes `pyoxidizer`. Differential Revision: https://phab.mercurial-scm.org/D10687
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 06 May 2021 16:07:01 -0700
parents df1767fa822d
children 73f1a10320d1
files contrib/packaging/hgpackaging/pyoxidizer.py
diffstat 1 files changed, 24 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/packaging/hgpackaging/pyoxidizer.py	Thu May 06 16:06:20 2021 -0700
+++ b/contrib/packaging/hgpackaging/pyoxidizer.py	Thu May 06 16:07:01 2021 -0700
@@ -68,16 +68,14 @@
     )
 
 
-def create_pyoxidizer_install_layout(
-    source_dir: pathlib.Path,
-    build_dir: pathlib.Path,
-    out_dir: pathlib.Path,
-    target_triple: str,
-):
-    """Build Mercurial with PyOxidizer and copy additional files into place.
+def run_pyoxidizer(
+    source_dir: pathlib.Path, build_dir: pathlib.Path, target_triple: str,
+) -> pathlib.Path:
+    """Run `pyoxidizer` in an environment with access to build dependencies.
 
-    After successful completion, ``out_dir`` contains files constituting a
-    Mercurial install.
+    Returns the output directory that pyoxidizer would have used for build
+    artifacts. Actual build artifacts are likely in a sub-directory with the
+    name of the pyoxidizer build target that was built.
     """
     # We need to make gettext binaries available for compiling i18n files.
     gettext_pkg, gettext_entry = download_entry('gettext', build_dir)
@@ -108,6 +106,23 @@
 
     subprocess.run(args, env=env, check=True)
 
+    return source_dir / "build" / "pyoxidizer" / target_triple / "release"
+
+
+def create_pyoxidizer_install_layout(
+    source_dir: pathlib.Path,
+    build_dir: pathlib.Path,
+    out_dir: pathlib.Path,
+    target_triple: str,
+):
+    """Build Mercurial with PyOxidizer and copy additional files into place.
+
+    After successful completion, ``out_dir`` contains files constituting a
+    Mercurial install.
+    """
+
+    run_pyoxidizer(source_dir, build_dir, target_triple)
+
     if "windows" in target_triple:
         target = "app_windows"
     else: