annotate contrib/packaging/hgpackaging/py2exe.py @ 42054:399ed3e86a49

py2exe: add workaround to allow bundling of hgext3rd.* extensions py2exe doesn't know how to handle namespace packages *at all*, so it treats them like normal packages. As a result, if we try and bundle hgext3rd.evolve in a py2exe build, it won't work if we install evolve into the virtualenv. In order to work around this, tortoisehg installs hgext3rd.evolve etc into its staged hg directory, since it doesn't use a virtualenv. As a workaround for us, we'll just allow any extra packages users want bundled are part of hg during the pseudo-install phase that py2exe uses. I'm not happy about this, but it *works*. As a sample of how you'd make an MSI with evolve bundled: import os import shutil import subprocess import tempfile def stage_evolve(version): """Stage evolve for inclusion in py2exe binary.""" with tempfile.TemporaryDirectory() as temp: evolve = os.path.join(temp, "evolve") subprocess.check_call([ "hg.exe", "clone", "https://www.mercurial-scm.org/repo/evolve/", "--update", version, evolve, ]) dest = os.path.join('..', 'hgext3rd', 'evolve') if os.path.exists(dest): shutil.rmtree(dest) shutil.copytree(os.path.join(evolve, "hgext3rd", "evolve"), dest) def main(): stage_evolve('tip') print("\0") print("hgext3rd") print("hgext3rd.evolve") print("hgext3rd.evolve.hack") print("hgext3rd.evolve.thirdparty") if __name__ == "__main__": main() is a script you can pass to the wix/build.py as --extra-packages-script, and the resulting .msi will have an hg binary with evolve baked in. users will still need to enable evolve in their hgrc, so you'd probably also want to bundle configs in your msi for an enterprise environment, but that's already easy to do with the support for extra features and wxs files in the wix build process. Differential Revision: https://phab.mercurial-scm.org/D6189
author Augie Fackler <augie@google.com>
date Wed, 03 Apr 2019 11:46:29 -0400
parents 715d3220ac4f
children 2372284d9457
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41915
a2e191a937a9 packaging: extract py2exe functionality to own module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41914
diff changeset
1 # py2exe.py - Functionality for performing py2exe builds.
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
2 #
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
3 # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
4 #
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
5 # This software may be used and distributed according to the terms of the
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
6 # GNU General Public License version 2 or any later version.
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
7
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
8 # no-check-code because Python 3 native.
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
9
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
10 import os
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
11 import pathlib
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
12 import subprocess
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
13
41911
dc7827a9ba64 packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41910
diff changeset
14 from .downloads import (
dc7827a9ba64 packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41910
diff changeset
15 download_entry,
dc7827a9ba64 packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41910
diff changeset
16 )
dc7827a9ba64 packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41910
diff changeset
17 from .util import (
dc7827a9ba64 packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41910
diff changeset
18 extract_tar_to_directory,
dc7827a9ba64 packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41910
diff changeset
19 extract_zip_to_directory,
41914
7d1211168863 packaging: extract python exe info to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41913
diff changeset
20 python_exe_info,
41911
dc7827a9ba64 packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41910
diff changeset
21 )
dc7827a9ba64 packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41910
diff changeset
22
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
23
41915
a2e191a937a9 packaging: extract py2exe functionality to own module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41914
diff changeset
24 def build_py2exe(source_dir: pathlib.Path, build_dir: pathlib.Path,
a2e191a937a9 packaging: extract py2exe functionality to own module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41914
diff changeset
25 python_exe: pathlib.Path, build_name: str,
41916
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41915
diff changeset
26 venv_requirements_txt: pathlib.Path,
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41915
diff changeset
27 extra_packages=None, extra_excludes=None,
42047
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
28 extra_dll_excludes=None,
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
29 extra_packages_script=None):
41915
a2e191a937a9 packaging: extract py2exe functionality to own module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41914
diff changeset
30 """Build Mercurial with py2exe.
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
31
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
32 Build files will be placed in ``build_dir``.
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
33
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34 py2exe's setup.py doesn't use setuptools. It doesn't have modern logic
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35 for finding the Python 2.7 toolchain. So, we require the environment
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
36 to already be configured with an active toolchain.
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
37 """
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
38 if 'VCINSTALLDIR' not in os.environ:
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
39 raise Exception('not running from a Visual C++ build environment; '
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
40 'execute the "Visual C++ <version> Command Prompt" '
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
41 'application shortcut or a vcsvarsall.bat file')
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
42
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
43 # Identity x86/x64 and validate the environment matches the Python
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
44 # architecture.
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
45 vc_x64 = r'\x64' in os.environ['LIB']
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
46
41914
7d1211168863 packaging: extract python exe info to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41913
diff changeset
47 py_info = python_exe_info(python_exe)
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
48
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
49 if vc_x64:
41914
7d1211168863 packaging: extract python exe info to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41913
diff changeset
50 if py_info['arch'] != '64bit':
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
51 raise Exception('architecture mismatch: Visual C++ environment '
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
52 'is configured for 64-bit but Python is 32-bit')
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
53 else:
41914
7d1211168863 packaging: extract python exe info to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41913
diff changeset
54 if py_info['arch'] != '32bit':
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
55 raise Exception('architecture mismatch: Visual C++ environment '
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
56 'is configured for 32-bit but Python is 64-bit')
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
57
41914
7d1211168863 packaging: extract python exe info to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41913
diff changeset
58 if py_info['py3']:
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
59 raise Exception('Only Python 2 is currently supported')
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
61 build_dir.mkdir(exist_ok=True)
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
62
41909
1e8fb6522fee packaging: move DOWNLOADS dict to hgpackaging.downloads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41908
diff changeset
63 gettext_pkg, gettext_entry = download_entry('gettext', build_dir)
1e8fb6522fee packaging: move DOWNLOADS dict to hgpackaging.downloads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41908
diff changeset
64 gettext_dep_pkg = download_entry('gettext-dep', build_dir)[0]
1e8fb6522fee packaging: move DOWNLOADS dict to hgpackaging.downloads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41908
diff changeset
65 virtualenv_pkg, virtualenv_entry = download_entry('virtualenv', build_dir)
1e8fb6522fee packaging: move DOWNLOADS dict to hgpackaging.downloads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41908
diff changeset
66 py2exe_pkg, py2exe_entry = download_entry('py2exe', build_dir)
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
67
41915
a2e191a937a9 packaging: extract py2exe functionality to own module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41914
diff changeset
68 venv_path = build_dir / ('venv-%s-%s' % (build_name,
a2e191a937a9 packaging: extract py2exe functionality to own module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41914
diff changeset
69 'x64' if vc_x64 else 'x86'))
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
70
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
71 gettext_root = build_dir / (
41909
1e8fb6522fee packaging: move DOWNLOADS dict to hgpackaging.downloads
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41908
diff changeset
72 'gettext-win-%s' % gettext_entry['version'])
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
73
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
74 if not gettext_root.exists():
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
75 extract_zip_to_directory(gettext_pkg, gettext_root)
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
76 extract_zip_to_directory(gettext_dep_pkg, gettext_root)
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
77
41912
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
78 # This assumes Python 2. We don't need virtualenv on Python 3.
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
79 virtualenv_src_path = build_dir / (
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
80 'virtualenv-%s' % virtualenv_entry['version'])
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
81 virtualenv_py = virtualenv_src_path / 'virtualenv.py'
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
82
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
83 if not virtualenv_src_path.exists():
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
84 extract_tar_to_directory(virtualenv_pkg, build_dir)
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
85
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
86 py2exe_source_path = build_dir / ('py2exe-%s' % py2exe_entry['version'])
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
87
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
88 if not py2exe_source_path.exists():
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
89 extract_zip_to_directory(py2exe_pkg, build_dir)
d4bf73ea06de packaging: extract virtualenv and py2exe to build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41911
diff changeset
90
41913
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
91 if not venv_path.exists():
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
92 print('creating virtualenv with dependencies')
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
93 subprocess.run(
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
94 [str(python_exe), str(virtualenv_py), str(venv_path)],
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
95 check=True)
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
96
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
97 venv_python = venv_path / 'Scripts' / 'python.exe'
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
98 venv_pip = venv_path / 'Scripts' / 'pip.exe'
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
99
41915
a2e191a937a9 packaging: extract py2exe functionality to own module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41914
diff changeset
100 subprocess.run([str(venv_pip), 'install', '-r', str(venv_requirements_txt)],
41913
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
101 check=True)
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
102
41913
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
103 # Force distutils to use VC++ settings from environment, which was
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
104 # validated above.
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
105 env = dict(os.environ)
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
106 env['DISTUTILS_USE_SDK'] = '1'
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
107 env['MSSdk'] = '1'
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
108
42047
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
109 if extra_packages_script:
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
110 more_packages = set(subprocess.check_output(
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
111 extra_packages_script,
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
112 cwd=build_dir).split(b'\0')[-1].strip().decode('utf-8').splitlines())
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
113 if more_packages:
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
114 if not extra_packages:
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
115 extra_packages = more_packages
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
116 else:
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
117 extra_packages |= more_packages
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41953
diff changeset
118
41916
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41915
diff changeset
119 if extra_packages:
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41915
diff changeset
120 env['HG_PY2EXE_EXTRA_PACKAGES'] = ' '.join(sorted(extra_packages))
42054
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 42047
diff changeset
121 hgext3rd_extras = sorted(
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 42047
diff changeset
122 e for e in extra_packages if e.startswith('hgext3rd.'))
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 42047
diff changeset
123 if hgext3rd_extras:
399ed3e86a49 py2exe: add workaround to allow bundling of hgext3rd.* extensions
Augie Fackler <augie@google.com>
parents: 42047
diff changeset
124 env['HG_PY2EXE_EXTRA_INSTALL_PACKAGES'] = ' '.join(hgext3rd_extras)
41916
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41915
diff changeset
125 if extra_excludes:
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41915
diff changeset
126 env['HG_PY2EXE_EXTRA_EXCLUDES'] = ' '.join(sorted(extra_excludes))
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41915
diff changeset
127 if extra_dll_excludes:
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41915
diff changeset
128 env['HG_PY2EXE_EXTRA_DLL_EXCLUDES'] = ' '.join(
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41915
diff changeset
129 sorted(extra_dll_excludes))
260305e8ddbd setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41915
diff changeset
130
41913
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
131 py2exe_py_path = venv_path / 'Lib' / 'site-packages' / 'py2exe'
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
132 if not py2exe_py_path.exists():
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
133 print('building py2exe')
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
134 subprocess.run([str(venv_python), 'setup.py', 'install'],
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
135 cwd=py2exe_source_path,
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
136 env=env,
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
137 check=True)
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
138
41913
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
139 # Register location of msgfmt and other binaries.
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
140 env['PATH'] = '%s%s%s' % (
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
141 env['PATH'], os.pathsep, str(gettext_root / 'bin'))
41853
d7dc4ac1ff84 inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
142
41913
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
143 print('building Mercurial')
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
144 subprocess.run(
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
145 [str(venv_python), 'setup.py',
41953
d6e3c16d48ab packaging: don't bundle DLLs in py2exe library.zip for x86 builds
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41916
diff changeset
146 'py2exe',
41913
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
147 'build_doc', '--html'],
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
148 cwd=str(source_dir),
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
149 env=env,
5e923355c595 packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41912
diff changeset
150 check=True)