D11092: pyoxidizer: add hooks to inject extra python packages and install files

2021-07-14 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We need this type of hook to inject our internal extension and resource files
  at Google. Presumably this could be useful to others, so instead of trying to
  carry an internal patch we've done this in a modular way that should be of
  value upstream.
  
  I'm extremely puzzled by the behavior of glob() on Windows, and I'll
  be filing at least one (probably two) bugs upstream about it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hgcli/pyoxidizer.bzl

CHANGE DETAILS

diff --git a/rust/hgcli/pyoxidizer.bzl b/rust/hgcli/pyoxidizer.bzl
--- a/rust/hgcli/pyoxidizer.bzl
+++ b/rust/hgcli/pyoxidizer.bzl
@@ -103,6 +103,12 @@
 exe.add_python_resources(
 exe.pip_install(["-r", ROOT + 
"/contrib/packaging/requirements-windows-py3.txt"]),
 )
+extra_packages = VARS.get("extra_py_packages", "")
+if extra_packages:
+for extra in extra_packages.split(","):
+extra_src, pkgs = extra.split("=")
+pkgs = pkgs.split(":")
+exe.add_python_resources(exe.read_package_root(extra_src, pkgs))
 
 return exe
 
@@ -144,6 +150,17 @@
 print("copying %s to %s" % (path, new_path))
 manifest.add_file(manifest.get_file(path), path = new_path)
 
+extra_install_files = VARS.get("extra_install_files", "")
+if extra_install_files:
+for extra in extra_install_files.split(","):
+print("adding extra files from %s" % extra)
+# TODO: I expected a ** glob to work, but it didn't.
+#
+# TODO: I know this has forward-slash paths. As far as I can tell,
+# backslashes don't ever match glob() expansions in 
+# tugger-starlark, even on Windows.
+manifest.add_manifest(glob(include=[extra + "/*/*"], 
strip_prefix=extra+"/"))
+
 # We also install a handful of additional files.
 EXTRA_CONTRIB_FILES = [
 "bash_completion",



To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D11093: packaging: add command line flag to add extra vars to pyoxidizer

2021-07-14 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This felt simpler than the previous incarnation of injecting
  content into the WiX build. I decided the easiest way to pass
  an arbitrary map into the process was some json - I may regret this,
  but time will tell on that.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/packaging/hgpackaging/cli.py
  contrib/packaging/hgpackaging/wix.py

CHANGE DETAILS

diff --git a/contrib/packaging/hgpackaging/wix.py 
b/contrib/packaging/hgpackaging/wix.py
--- a/contrib/packaging/hgpackaging/wix.py
+++ b/contrib/packaging/hgpackaging/wix.py
@@ -8,6 +8,7 @@
 # no-check-code because Python 3 native.
 
 import collections
+import json
 import os
 import pathlib
 import re
@@ -386,6 +387,7 @@
 extra_wxs: typing.Optional[typing.Dict[str, str]] = None,
 extra_features: typing.Optional[typing.List[str]] = None,
 signing_info: typing.Optional[typing.Dict[str, str]] = None,
+extra_pyoxidizer_vars=None,
 ):
 """Build a WiX MSI installer using PyOxidizer."""
 hg_build_dir = source_dir / "build"
@@ -418,6 +420,9 @@
 if signing_info["timestamp_url"]:
 build_vars["TIME_STAMP_SERVER_URL"] = signing_info["timestamp_url"]
 
+if extra_pyoxidizer_vars:
+build_vars.update(json.loads(extra_pyoxidizer_vars))
+
 if extra_wxs:
 raise Exception(
 "support for extra .wxs files has been temporarily dropped"
diff --git a/contrib/packaging/hgpackaging/cli.py 
b/contrib/packaging/hgpackaging/cli.py
--- a/contrib/packaging/hgpackaging/cli.py
+++ b/contrib/packaging/hgpackaging/cli.py
@@ -64,6 +64,7 @@
 extra_packages_script=None,
 extra_wxs=None,
 extra_features=None,
+extra_pyoxidizer_vars=None,
 ):
 if not pyoxidizer_target and not python:
 raise Exception("--python required unless building with PyOxidizer")
@@ -105,7 +106,7 @@
 "timestamp_url": sign_timestamp_url,
 }
 
-fn(**kwargs)
+fn(**kwargs, extra_pyoxidizer_vars=extra_pyoxidizer_vars)
 
 
 def get_parser():
@@ -168,6 +169,12 @@
 "in the installer from the extra wxs files"
 ),
 )
+
+sp.add_argument(
+"--extra-pyoxidizer-vars",
+help="json map of extra variables to pass to pyoxidizer",
+)
+
 sp.set_defaults(func=build_wix)
 
 return parser



To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel