diff contrib/packaging/hgpackaging/py2exe.py @ 41921:260305e8ddbd

setup: configure py2exe config via environment variables The Inno Setup and WiX installers ship a different set of packages with py2exe builds. And there are multiple WiX installer variants (e.g. TortoiseHG). Since there are multiple variants of py2exe configs and they can be defined by entities not in our repository, let's provide a mechanism for setup.py to supplement behavior via environment variables. This is slighly less hacky than a setup.cfg file IMO since the caller doesn't need to worry about mutating global state of the source directory. Differential Revision: https://phab.mercurial-scm.org/D6092
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 07 Mar 2019 12:15:32 -0800
parents a2e191a937a9
children d6e3c16d48ab
line wrap: on
line diff
--- a/contrib/packaging/hgpackaging/py2exe.py	Thu Mar 07 15:43:54 2019 -0800
+++ b/contrib/packaging/hgpackaging/py2exe.py	Thu Mar 07 12:15:32 2019 -0800
@@ -23,7 +23,9 @@
 
 def build_py2exe(source_dir: pathlib.Path, build_dir: pathlib.Path,
                  python_exe: pathlib.Path, build_name: str,
-                 venv_requirements_txt: pathlib.Path):
+                 venv_requirements_txt: pathlib.Path,
+                 extra_packages=None, extra_excludes=None,
+                 extra_dll_excludes=None):
     """Build Mercurial with py2exe.
 
     Build files will be placed in ``build_dir``.
@@ -103,6 +105,14 @@
     env['DISTUTILS_USE_SDK'] = '1'
     env['MSSdk'] = '1'
 
+    if extra_packages:
+        env['HG_PY2EXE_EXTRA_PACKAGES'] = ' '.join(sorted(extra_packages))
+    if extra_excludes:
+        env['HG_PY2EXE_EXTRA_EXCLUDES'] = ' '.join(sorted(extra_excludes))
+    if extra_dll_excludes:
+        env['HG_PY2EXE_EXTRA_DLL_EXCLUDES'] = ' '.join(
+            sorted(extra_dll_excludes))
+
     py2exe_py_path = venv_path / 'Lib' / 'site-packages' / 'py2exe'
     if not py2exe_py_path.exists():
         print('building py2exe')