annotate rust/hgcli/pyoxidizer.bzl @ 48740:6387562e68b3 stable

contrib: refer to RHEL and derivatives instead of CentOS specifically Differential Revision: https://phab.mercurial-scm.org/D12182
author Mathias De Mare <mathias.de_mare@nokia.com>
date Tue, 15 Feb 2022 15:33:33 +0100
parents 1a420a13eeea
children 06107198f95b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47205
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
1 # The following variables can be passed in as parameters:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
2 #
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
3 # VERSION
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
4 # Version string of program being produced.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
5 #
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
6 # MSI_NAME
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
7 # Root name of MSI installer.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
8 #
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
9 # EXTRA_MSI_FEATURES
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
10 # ; delimited string of extra features to advertise in the built MSA.
47206
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
11 #
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
12 # SIGNING_PFX_PATH
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
13 # Path to code signing certificate to use.
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
14 #
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
15 # SIGNING_PFX_PASSWORD
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
16 # Password to code signing PFX file defined by SIGNING_PFX_PATH.
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
17 #
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
18 # SIGNING_SUBJECT_NAME
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
19 # String fragment in code signing certificate subject name used to find
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
20 # code signing certificate in Windows certificate store.
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
21 #
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
22 # TIME_STAMP_SERVER_URL
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
23 # URL of time-stamp token authority (RFC 3161) servers to stamp code signatures.
47205
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
24
44639
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
25 ROOT = CWD + "/../.."
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
26
48248
7f23a472068f pyoxidizer: default to a meaningless release instead of hardcoding 5.8
Raphaël Gomès <rgomes@octobus.net>
parents: 48217
diff changeset
27 VERSION = VARS.get("VERSION", "0.0")
47205
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
28 MSI_NAME = VARS.get("MSI_NAME", "mercurial")
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
29 EXTRA_MSI_FEATURES = VARS.get("EXTRA_MSI_FEATURES")
47206
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
30 SIGNING_PFX_PATH = VARS.get("SIGNING_PFX_PATH")
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
31 SIGNING_PFX_PASSWORD = VARS.get("SIGNING_PFX_PASSWORD", "")
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
32 SIGNING_SUBJECT_NAME = VARS.get("SIGNING_SUBJECT_NAME")
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
33 TIME_STAMP_SERVER_URL = VARS.get("TIME_STAMP_SERVER_URL", "http://timestamp.digicert.com")
47205
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
34
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
35 IS_WINDOWS = "windows" in BUILD_TARGET_TRIPLE
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
36
48299
1a420a13eeea pyoxidizer: use in-memory resources on non-Windows platforms
Kyle Lippincott <spectral@google.com>
parents: 48277
diff changeset
37 # Use in-memory resources for all resources. If false, most of the Python
1a420a13eeea pyoxidizer: use in-memory resources on non-Windows platforms
Kyle Lippincott <spectral@google.com>
parents: 48277
diff changeset
38 # stdlib will be in memory, but other things such as Mercurial itself will not
1a420a13eeea pyoxidizer: use in-memory resources on non-Windows platforms
Kyle Lippincott <spectral@google.com>
parents: 48277
diff changeset
39 # be. See the comment in resource_callback, below.
1a420a13eeea pyoxidizer: use in-memory resources on non-Windows platforms
Kyle Lippincott <spectral@google.com>
parents: 48277
diff changeset
40 USE_IN_MEMORY_RESOURCES = not IS_WINDOWS
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
41
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
42 # Code to run in Python interpreter.
47848
5f2b0d34f24d pyoxidizer: wrap the pyoxidizer script on multiple line
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47643
diff changeset
43 RUN_CODE = """
47850
b962a913ee3b pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47848
diff changeset
44 import os
b962a913ee3b pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47848
diff changeset
45 import sys
b962a913ee3b pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47848
diff changeset
46 extra_path = os.environ.get('PYTHONPATH')
b962a913ee3b pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47848
diff changeset
47 if extra_path is not None:
b962a913ee3b pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47848
diff changeset
48 # extensions and hooks expect a working python environment
b962a913ee3b pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47848
diff changeset
49 # We do not prepend the values because the Mercurial library wants to be in
b962a913ee3b pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47848
diff changeset
50 # the front of the sys.path to avoid picking up other installations.
b962a913ee3b pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47848
diff changeset
51 sys.path.extend(extra_path.split(os.pathsep))
47865
95af358fcdfe pyoxidizer: add user-site to `sys.path` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 47850
diff changeset
52 # Add user site to sys.path to load extensions without the full path
95af358fcdfe pyoxidizer: add user-site to `sys.path` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 47850
diff changeset
53 if os.name == 'nt':
95af358fcdfe pyoxidizer: add user-site to `sys.path` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 47850
diff changeset
54 vi = sys.version_info
47880
769cd5703b2c hg: don't attempt to extend `sys.path` with the user site without `APPDATA`
Matt Harbison <matt_harbison@yahoo.com>
parents: 47865
diff changeset
55 appdata = os.environ.get('APPDATA')
769cd5703b2c hg: don't attempt to extend `sys.path` with the user site without `APPDATA`
Matt Harbison <matt_harbison@yahoo.com>
parents: 47865
diff changeset
56 if appdata:
769cd5703b2c hg: don't attempt to extend `sys.path` with the user site without `APPDATA`
Matt Harbison <matt_harbison@yahoo.com>
parents: 47865
diff changeset
57 sys.path.append(
769cd5703b2c hg: don't attempt to extend `sys.path` with the user site without `APPDATA`
Matt Harbison <matt_harbison@yahoo.com>
parents: 47865
diff changeset
58 os.path.join(
769cd5703b2c hg: don't attempt to extend `sys.path` with the user site without `APPDATA`
Matt Harbison <matt_harbison@yahoo.com>
parents: 47865
diff changeset
59 appdata,
769cd5703b2c hg: don't attempt to extend `sys.path` with the user site without `APPDATA`
Matt Harbison <matt_harbison@yahoo.com>
parents: 47865
diff changeset
60 'Python',
769cd5703b2c hg: don't attempt to extend `sys.path` with the user site without `APPDATA`
Matt Harbison <matt_harbison@yahoo.com>
parents: 47865
diff changeset
61 'Python%d%d' % (vi[0], vi[1]),
769cd5703b2c hg: don't attempt to extend `sys.path` with the user site without `APPDATA`
Matt Harbison <matt_harbison@yahoo.com>
parents: 47865
diff changeset
62 'site-packages',
769cd5703b2c hg: don't attempt to extend `sys.path` with the user site without `APPDATA`
Matt Harbison <matt_harbison@yahoo.com>
parents: 47865
diff changeset
63 )
47865
95af358fcdfe pyoxidizer: add user-site to `sys.path` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 47850
diff changeset
64 )
48217
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
65 elif sys.platform == "darwin":
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
66 vi = sys.version_info
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
67
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
68 def joinuser(*args):
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
69 return os.path.expanduser(os.path.join(*args))
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
70
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
71 # Note: site.py uses `sys._framework` instead of hardcoding "Python" as the
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
72 # 3rd arg, but that is set to an empty string in an oxidized binary. It
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
73 # has a fallback to ~/.local when `sys._framework` isn't set, but we want
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
74 # to match what the system python uses, so it sees pip installed stuff.
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
75 usersite = joinuser("~", "Library", "Python",
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
76 "%d.%d" % vi[:2], "lib/python/site-packages")
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
77
e10f5dc7f5bf pyoxidizer: add the user site to `sys.path` on macOS
Matt Harbison <matt_harbison@yahoo.com>
parents: 48216
diff changeset
78 sys.path.append(usersite)
47848
5f2b0d34f24d pyoxidizer: wrap the pyoxidizer script on multiple line
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47643
diff changeset
79 import hgdemandimport;
5f2b0d34f24d pyoxidizer: wrap the pyoxidizer script on multiple line
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47643
diff changeset
80 hgdemandimport.enable();
5f2b0d34f24d pyoxidizer: wrap the pyoxidizer script on multiple line
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47643
diff changeset
81 from mercurial import dispatch;
5f2b0d34f24d pyoxidizer: wrap the pyoxidizer script on multiple line
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47643
diff changeset
82 dispatch.run();
5f2b0d34f24d pyoxidizer: wrap the pyoxidizer script on multiple line
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47643
diff changeset
83 """
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
84
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
85 set_build_path(ROOT + "/build/pyoxidizer")
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
86
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
87 def make_distribution():
47211
159d2de3286c pyoxidizer: use Python 3.9 (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47206
diff changeset
88 return default_python_distribution(python_version = "3.9")
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
89
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
90 def resource_callback(policy, resource):
48267
c900d962e38b pyoxidizer: disable using in-memory resources
Kyle Lippincott <spectral@google.com>
parents: 48248
diff changeset
91 if USE_IN_MEMORY_RESOURCES:
45831
f14c33b2e497 pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents: 45752
diff changeset
92 resource.add_location = "in-memory"
f14c33b2e497 pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents: 45752
diff changeset
93 return
45879
5d73d3053d92 pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents: 45832
diff changeset
94
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
95 # We use a custom resource routing policy to influence where things are loaded
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
96 # from.
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
97 #
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
98 # For Python modules and resources, we load from memory if they are in
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
99 # the standard library and from the filesystem if not. This is because
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
100 # parts of Mercurial and some 3rd party packages aren't yet compatible
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
101 # with memory loading.
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
102 #
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
103 # For Python extension modules, we load from the filesystem because
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
104 # this yields greatest compatibility.
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
105 if type(resource) in ("PythonModuleSource", "PythonPackageResource", "PythonPackageDistributionResource"):
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
106 if resource.is_stdlib:
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
107 resource.add_location = "in-memory"
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
108 else:
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
109 resource.add_location = "filesystem-relative:lib"
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
110
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
111 elif type(resource) == "PythonExtensionModule":
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
112 resource.add_location = "filesystem-relative:lib"
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
113
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
114 def make_exe(dist):
44822
118f067f6bd1 pyoxidizer: formatting bazel definitions
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents: 44763
diff changeset
115 """Builds a Rust-wrapped Mercurial binary."""
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
116 packaging_policy = dist.make_python_packaging_policy()
45879
5d73d3053d92 pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents: 45832
diff changeset
117
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
118 # Extension may depend on any Python functionality. Include all
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
119 # extensions.
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
120 packaging_policy.extension_module_filter = "all"
45749
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
121 packaging_policy.resources_location = "in-memory"
48267
c900d962e38b pyoxidizer: disable using in-memory resources
Kyle Lippincott <spectral@google.com>
parents: 48248
diff changeset
122 if not USE_IN_MEMORY_RESOURCES:
45831
f14c33b2e497 pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents: 45752
diff changeset
123 packaging_policy.resources_location_fallback = "filesystem-relative:lib"
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
124 packaging_policy.register_resource_callback(resource_callback)
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
125
45749
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
126 config = dist.make_python_interpreter_config()
47204
3380848c6e04 pyoxidizer: use allocator_backend instead of raw_allocator
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47203
diff changeset
127 config.allocator_backend = "default"
45832
867385f45559 pyoxidizer: switch to modern config using run_command instead of run_mode
Augie Fackler <augie@google.com>
parents: 45831
diff changeset
128 config.run_command = RUN_CODE
45879
5d73d3053d92 pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents: 45832
diff changeset
129
45749
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
130 # We want to let the user load extensions from the file system
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
131 config.filesystem_importer = True
45879
5d73d3053d92 pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents: 45832
diff changeset
132
45749
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
133 # We need this to make resourceutil happy, since it looks for sys.frozen.
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
134 config.sys_frozen = True
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
135 config.legacy_windows_stdio = True
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
136
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
137 exe = dist.to_python_executable(
44639
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
138 name = "hg",
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
139 packaging_policy = packaging_policy,
44639
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
140 config = config,
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
141 )
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
142
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
143 # Add Mercurial to resources.
48272
f6b045910d82 pyoxidizer: force pip to not use pep517 in order to be able to install hg
Raphaël Gomès <rgomes@octobus.net>
parents: 47885
diff changeset
144 exe.add_python_resources(exe.pip_install(["--verbose", "--no-use-pep517", ROOT]))
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
145
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
146 # On Windows, we install extra packages for convenience.
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44822
diff changeset
147 if IS_WINDOWS:
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
148 exe.add_python_resources(
46022
cd7f36337741 pyoxidizer: point to the py3 requirements instead of py2 on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 45752
diff changeset
149 exe.pip_install(["-r", ROOT + "/contrib/packaging/requirements-windows-py3.txt"]),
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
150 )
47643
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
151 extra_packages = VARS.get("extra_py_packages", "")
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
152 if extra_packages:
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
153 for extra in extra_packages.split(","):
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
154 extra_src, pkgs = extra.split("=")
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
155 pkgs = pkgs.split(":")
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
156 exe.add_python_resources(exe.read_package_root(extra_src, pkgs))
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
157
44639
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
158 return exe
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
159
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
160 def make_manifest(dist, exe):
44639
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
161 m = FileManifest()
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
162 m.add_python_resource(".", exe)
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
163
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
164 return m
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
165
47205
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
166
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
167 # This adjusts the InstallManifest produced from exe generation to provide
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
168 # additional files found in a Windows install layout.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
169 def make_windows_install_layout(manifest):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
170 # Copy various files to new install locations. This can go away once
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
171 # we're using the importlib resource reader.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
172 RECURSIVE_COPIES = {
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
173 "lib/mercurial/locale/": "locale/",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
174 "lib/mercurial/templates/": "templates/",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
175 }
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
176 for (search, replace) in RECURSIVE_COPIES.items():
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
177 for path in manifest.paths():
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
178 if path.startswith(search):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
179 new_path = path.replace(search, replace)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
180 print("copy %s to %s" % (path, new_path))
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
181 file = manifest.get_file(path)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
182 manifest.add_file(file, path = new_path)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
183
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
184 # Similar to above, but with filename pattern matching.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
185 # lib/mercurial/helptext/**/*.txt -> helptext/
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
186 # lib/mercurial/defaultrc/*.rc -> defaultrc/
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
187 for path in manifest.paths():
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
188 if path.startswith("lib/mercurial/helptext/") and path.endswith(".txt"):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
189 new_path = path[len("lib/mercurial/"):]
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
190 elif path.startswith("lib/mercurial/defaultrc/") and path.endswith(".rc"):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
191 new_path = path[len("lib/mercurial/"):]
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
192 else:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
193 continue
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
194
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
195 print("copying %s to %s" % (path, new_path))
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
196 manifest.add_file(manifest.get_file(path), path = new_path)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
197
47643
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
198 extra_install_files = VARS.get("extra_install_files", "")
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
199 if extra_install_files:
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
200 for extra in extra_install_files.split(","):
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
201 print("adding extra files from %s" % extra)
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
202 # TODO: I expected a ** glob to work, but it didn't.
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
203 #
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
204 # TODO: I know this has forward-slash paths. As far as I can tell,
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
205 # backslashes don't ever match glob() expansions in
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
206 # tugger-starlark, even on Windows.
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
207 manifest.add_manifest(glob(include=[extra + "/*/*"], strip_prefix=extra+"/"))
11f834e7177d pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents: 47211
diff changeset
208
47205
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
209 # We also install a handful of additional files.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
210 EXTRA_CONTRIB_FILES = [
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
211 "bash_completion",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
212 "hgweb.fcgi",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
213 "hgweb.wsgi",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
214 "logo-droplets.svg",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
215 "mercurial.el",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
216 "mq.el",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
217 "tcsh_completion",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
218 "tcsh_completion_build.sh",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
219 "xml.rnc",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
220 "zsh_completion",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
221 ]
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
222
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
223 for f in EXTRA_CONTRIB_FILES:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
224 manifest.add_file(FileContent(path = ROOT + "/contrib/" + f), directory = "contrib")
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
225
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
226 # Individual files with full source to destination path mapping.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
227 EXTRA_FILES = {
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
228 "contrib/hgk": "contrib/hgk.tcl",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
229 "contrib/win32/postinstall.txt": "ReleaseNotes.txt",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
230 "contrib/win32/ReadMe.html": "ReadMe.html",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
231 "doc/style.css": "doc/style.css",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
232 "COPYING": "Copying.txt",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
233 }
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
234
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
235 for source, dest in EXTRA_FILES.items():
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
236 print("adding extra file %s" % dest)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
237 manifest.add_file(FileContent(path = ROOT + "/" + source), path = dest)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
238
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
239 # And finally some wildcard matches.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
240 manifest.add_manifest(glob(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
241 include = [ROOT + "/contrib/vim/*"],
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
242 strip_prefix = ROOT + "/"
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
243 ))
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
244 manifest.add_manifest(glob(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
245 include = [ROOT + "/doc/*.html"],
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
246 strip_prefix = ROOT + "/"
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
247 ))
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
248
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
249 # But we don't ship hg-ssh on Windows, so exclude its documentation.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
250 manifest.remove("doc/hg-ssh.8.html")
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
251
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
252 return manifest
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
253
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
254
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
255 def make_msi(manifest):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
256 manifest = make_windows_install_layout(manifest)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
257
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
258 if "x86_64" in BUILD_TARGET_TRIPLE:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
259 platform = "x64"
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
260 else:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
261 platform = "x86"
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
262
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
263 manifest.add_file(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
264 FileContent(path = ROOT + "/contrib/packaging/wix/COPYING.rtf"),
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
265 path = "COPYING.rtf",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
266 )
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
267 manifest.remove("Copying.txt")
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
268 manifest.add_file(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
269 FileContent(path = ROOT + "/contrib/win32/mercurial.ini"),
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
270 path = "defaultrc/mercurial.rc",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
271 )
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
272 manifest.add_file(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
273 FileContent(filename = "editor.rc", content = "[ui]\neditor = notepad\n"),
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
274 path = "defaultrc/editor.rc",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
275 )
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
276
47885
3962503cd1e8 pyoxidizer: add arch to PyOxidizer MSIs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47884
diff changeset
277 wix = WiXInstaller(
3962503cd1e8 pyoxidizer: add arch to PyOxidizer MSIs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47884
diff changeset
278 "hg",
3962503cd1e8 pyoxidizer: add arch to PyOxidizer MSIs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47884
diff changeset
279 "%s-%s-%s.msi" % (MSI_NAME, VERSION, platform),
3962503cd1e8 pyoxidizer: add arch to PyOxidizer MSIs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47884
diff changeset
280 arch = platform,
3962503cd1e8 pyoxidizer: add arch to PyOxidizer MSIs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47884
diff changeset
281 )
47205
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
282
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
283 # Materialize files in the manifest to the install layout.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
284 wix.add_install_files(manifest)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
285
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
286 # From mercurial.wxs.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
287 wix.install_files_root_directory_id = "INSTALLDIR"
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
288
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
289 # Pull in our custom .wxs files.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
290 defines = {
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
291 "PyOxidizer": "1",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
292 "Platform": platform,
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
293 "Version": VERSION,
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
294 "Comments": "Installs Mercurial version %s" % VERSION,
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
295 "PythonVersion": "3",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
296 "MercurialHasLib": "1",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
297 }
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
298
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
299 if EXTRA_MSI_FEATURES:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
300 defines["MercurialExtraFeatures"] = EXTRA_MSI_FEATURES
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
301
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
302 wix.add_wxs_file(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
303 ROOT + "/contrib/packaging/wix/mercurial.wxs",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
304 preprocessor_parameters=defines,
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
305 )
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
306
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
307 # Our .wxs references to other files. Pull those into the build environment.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
308 for f in ("defines.wxi", "guids.wxi", "COPYING.rtf"):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
309 wix.add_build_file(f, ROOT + "/contrib/packaging/wix/" + f)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
310
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
311 wix.add_build_file("mercurial.ico", ROOT + "/contrib/win32/mercurial.ico")
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
312
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
313 return wix
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
314
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
315
47206
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
316 def register_code_signers():
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
317 if not IS_WINDOWS:
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
318 return
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
319
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
320 if SIGNING_PFX_PATH:
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
321 signer = code_signer_from_pfx_file(SIGNING_PFX_PATH, SIGNING_PFX_PASSWORD)
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
322 elif SIGNING_SUBJECT_NAME:
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
323 signer = code_signer_from_windows_store_subject(SIGNING_SUBJECT_NAME)
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
324 else:
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
325 signer = None
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
326
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
327 if signer:
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
328 signer.set_time_stamp_server(TIME_STAMP_SERVER_URL)
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
329 signer.activate()
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
330
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
331
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
332 register_code_signers()
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47205
diff changeset
333
47203
9438e9b7321a pyoxidizer: simplify targets
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47201
diff changeset
334 register_target("distribution", make_distribution)
9438e9b7321a pyoxidizer: simplify targets
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47201
diff changeset
335 register_target("exe", make_exe, depends = ["distribution"])
9438e9b7321a pyoxidizer: simplify targets
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47201
diff changeset
336 register_target("app", make_manifest, depends = ["distribution", "exe"], default = True)
47205
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47204
diff changeset
337 register_target("msi", make_msi, depends = ["app"])
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
338
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
339 resolve_targets()