Patchwork D10687: packaging: extract invocation of pyoxidizer to own function

login
register
mail settings
Submitter phabricator
Date May 7, 2021, 12:01 a.m.
Message ID <differential-rev-PHID-DREV-rnzsix3bjl637y4bs66b-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49004/
State Superseded
Headers show

Comments

phabricator - May 7, 2021, 12:01 a.m.
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10687

AFFECTED FILES
  contrib/packaging/hgpackaging/pyoxidizer.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/contrib/packaging/hgpackaging/pyoxidizer.py b/contrib/packaging/hgpackaging/pyoxidizer.py
--- a/contrib/packaging/hgpackaging/pyoxidizer.py
+++ b/contrib/packaging/hgpackaging/pyoxidizer.py
@@ -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: