changeset 47643:11f834e7177d

pyoxidizer: add hooks to inject extra python packages and install files 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. Differential Revision: https://phab.mercurial-scm.org/D11092
author Augie Fackler <augie@google.com>
date Mon, 12 Jul 2021 15:56:25 -0400
parents 0caac68a5c3c
children be37bb8d0c7c
files rust/hgcli/pyoxidizer.bzl
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hgcli/pyoxidizer.bzl	Fri Jul 09 11:42:48 2021 -0400
+++ b/rust/hgcli/pyoxidizer.bzl	Mon Jul 12 15:56:25 2021 -0400
@@ -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",