author | Raphaël Gomès <rgomes@octobus.net> |
Wed, 20 Oct 2021 16:54:43 +0200 | |
branch | stable |
changeset 48272 | f6b045910d82 |
parent 47885 | 3962503cd1e8 |
child 48277 | 96aa3a68d3b5 |
permissions | -rw-r--r-- |
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 |
|
47205
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
27 |
VERSION = VARS.get("VERSION", "5.8") |
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 |
|
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
37 |
# 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
|
38 |
RUN_CODE = """ |
47850
b962a913ee3b
pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47848
diff
changeset
|
39 |
import os |
b962a913ee3b
pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47848
diff
changeset
|
40 |
import sys |
b962a913ee3b
pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47848
diff
changeset
|
41 |
extra_path = os.environ.get('PYTHONPATH') |
b962a913ee3b
pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47848
diff
changeset
|
42 |
if extra_path is not None: |
b962a913ee3b
pyoxidizer: re-install PYTHONPATH behavior
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47848
diff
changeset
|
43 |
# 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
|
44 |
# 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
|
45 |
# 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
|
46 |
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
|
47 |
# 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
|
48 |
if os.name == 'nt': |
95af358fcdfe
pyoxidizer: add user-site to `sys.path` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
47850
diff
changeset
|
49 |
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
|
50 |
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
|
51 |
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
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
'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
|
56 |
'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
|
57 |
'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
|
58 |
) |
47865
95af358fcdfe
pyoxidizer: add user-site to `sys.path` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
47850
diff
changeset
|
59 |
) |
47848
5f2b0d34f24d
pyoxidizer: wrap the pyoxidizer script on multiple line
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47643
diff
changeset
|
60 |
import hgdemandimport; |
5f2b0d34f24d
pyoxidizer: wrap the pyoxidizer script on multiple line
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47643
diff
changeset
|
61 |
hgdemandimport.enable(); |
5f2b0d34f24d
pyoxidizer: wrap the pyoxidizer script on multiple line
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47643
diff
changeset
|
62 |
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
|
63 |
dispatch.run(); |
5f2b0d34f24d
pyoxidizer: wrap the pyoxidizer script on multiple line
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47643
diff
changeset
|
64 |
""" |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
65 |
|
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
66 |
set_build_path(ROOT + "/build/pyoxidizer") |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
67 |
|
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
68 |
def make_distribution(): |
47211
159d2de3286c
pyoxidizer: use Python 3.9 (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47206
diff
changeset
|
69 |
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
|
70 |
|
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
71 |
def resource_callback(policy, resource): |
45831
f14c33b2e497
pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents:
45752
diff
changeset
|
72 |
if not IS_WINDOWS: |
f14c33b2e497
pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents:
45752
diff
changeset
|
73 |
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
|
74 |
return |
45879
5d73d3053d92
pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents:
45832
diff
changeset
|
75 |
|
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
76 |
# 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
|
77 |
# from. |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
78 |
# |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
79 |
# 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
|
80 |
# 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
|
81 |
# 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
|
82 |
# with memory loading. |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
83 |
# |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
84 |
# 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
|
85 |
# this yields greatest compatibility. |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
86 |
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
|
87 |
if resource.is_stdlib: |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
88 |
resource.add_location = "in-memory" |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
89 |
else: |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
90 |
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
|
91 |
|
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
92 |
elif type(resource) == "PythonExtensionModule": |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
93 |
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
|
94 |
|
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
95 |
def make_exe(dist): |
44822
118f067f6bd1
pyoxidizer: formatting bazel definitions
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44763
diff
changeset
|
96 |
"""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
|
97 |
packaging_policy = dist.make_python_packaging_policy() |
45879
5d73d3053d92
pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents:
45832
diff
changeset
|
98 |
|
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
99 |
# 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
|
100 |
# extensions. |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
101 |
packaging_policy.extension_module_filter = "all" |
45749
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
102 |
packaging_policy.resources_location = "in-memory" |
45831
f14c33b2e497
pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents:
45752
diff
changeset
|
103 |
if IS_WINDOWS: |
f14c33b2e497
pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents:
45752
diff
changeset
|
104 |
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
|
105 |
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
|
106 |
|
45749
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
107 |
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
|
108 |
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
|
109 |
config.run_command = RUN_CODE |
45879
5d73d3053d92
pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents:
45832
diff
changeset
|
110 |
|
45749
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
111 |
# 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
|
112 |
config.filesystem_importer = True |
45879
5d73d3053d92
pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents:
45832
diff
changeset
|
113 |
|
45749
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
114 |
# 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
|
115 |
config.sys_frozen = True |
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
116 |
config.legacy_windows_stdio = True |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
117 |
|
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
118 |
exe = dist.to_python_executable( |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
119 |
name = "hg", |
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
120 |
packaging_policy = packaging_policy, |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
121 |
config = config, |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
122 |
) |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
123 |
|
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
124 |
# 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
|
125 |
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
|
126 |
|
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
127 |
# 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
|
128 |
if IS_WINDOWS: |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
129 |
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
|
130 |
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
|
131 |
) |
47643
11f834e7177d
pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents:
47211
diff
changeset
|
132 |
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
|
133 |
if extra_packages: |
11f834e7177d
pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents:
47211
diff
changeset
|
134 |
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
|
135 |
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
|
136 |
pkgs = pkgs.split(":") |
11f834e7177d
pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents:
47211
diff
changeset
|
137 |
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
|
138 |
|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
139 |
return exe |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
140 |
|
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
141 |
def make_manifest(dist, exe): |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
142 |
m = FileManifest() |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
143 |
m.add_python_resource(".", exe) |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
144 |
|
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
145 |
return m |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
146 |
|
47205
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
147 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
148 |
# 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
|
149 |
# additional files found in a Windows install layout. |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
150 |
def make_windows_install_layout(manifest): |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
151 |
# 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
|
152 |
# we're using the importlib resource reader. |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
153 |
RECURSIVE_COPIES = { |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
154 |
"lib/mercurial/locale/": "locale/", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
155 |
"lib/mercurial/templates/": "templates/", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
156 |
} |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
157 |
for (search, replace) in RECURSIVE_COPIES.items(): |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
158 |
for path in manifest.paths(): |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
159 |
if path.startswith(search): |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
160 |
new_path = path.replace(search, replace) |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
161 |
print("copy %s to %s" % (path, new_path)) |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
162 |
file = manifest.get_file(path) |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
163 |
manifest.add_file(file, path = new_path) |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
164 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
165 |
# Similar to above, but with filename pattern matching. |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
166 |
# lib/mercurial/helptext/**/*.txt -> helptext/ |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
167 |
# lib/mercurial/defaultrc/*.rc -> defaultrc/ |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
168 |
for path in manifest.paths(): |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
169 |
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
|
170 |
new_path = path[len("lib/mercurial/"):] |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
171 |
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
|
172 |
new_path = path[len("lib/mercurial/"):] |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
173 |
else: |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
174 |
continue |
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 |
print("copying %s to %s" % (path, new_path)) |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
177 |
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
|
178 |
|
47643
11f834e7177d
pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents:
47211
diff
changeset
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
# 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
|
184 |
# |
11f834e7177d
pyoxidizer: add hooks to inject extra python packages and install files
Augie Fackler <augie@google.com>
parents:
47211
diff
changeset
|
185 |
# 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
|
186 |
# 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
|
187 |
# 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
|
188 |
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
|
189 |
|
47205
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
190 |
# We also install a handful of additional files. |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
191 |
EXTRA_CONTRIB_FILES = [ |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
192 |
"bash_completion", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
193 |
"hgweb.fcgi", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
194 |
"hgweb.wsgi", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
195 |
"logo-droplets.svg", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
196 |
"mercurial.el", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
197 |
"mq.el", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
198 |
"tcsh_completion", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
199 |
"tcsh_completion_build.sh", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
200 |
"xml.rnc", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
201 |
"zsh_completion", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
202 |
] |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
203 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
204 |
for f in EXTRA_CONTRIB_FILES: |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
205 |
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
|
206 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
207 |
# 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
|
208 |
EXTRA_FILES = { |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
209 |
"contrib/hgk": "contrib/hgk.tcl", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
210 |
"contrib/win32/postinstall.txt": "ReleaseNotes.txt", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
211 |
"contrib/win32/ReadMe.html": "ReadMe.html", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
212 |
"doc/style.css": "doc/style.css", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
213 |
"COPYING": "Copying.txt", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
214 |
} |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
215 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
216 |
for source, dest in EXTRA_FILES.items(): |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
217 |
print("adding extra file %s" % dest) |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
218 |
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
|
219 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
220 |
# And finally some wildcard matches. |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
221 |
manifest.add_manifest(glob( |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
222 |
include = [ROOT + "/contrib/vim/*"], |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
223 |
strip_prefix = ROOT + "/" |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
224 |
)) |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
225 |
manifest.add_manifest(glob( |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
226 |
include = [ROOT + "/doc/*.html"], |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
227 |
strip_prefix = ROOT + "/" |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
228 |
)) |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
229 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
230 |
# 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
|
231 |
manifest.remove("doc/hg-ssh.8.html") |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
232 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
233 |
return manifest |
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 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
236 |
def make_msi(manifest): |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
237 |
manifest = make_windows_install_layout(manifest) |
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 |
if "x86_64" in BUILD_TARGET_TRIPLE: |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
240 |
platform = "x64" |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
241 |
else: |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
242 |
platform = "x86" |
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_file( |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
245 |
FileContent(path = ROOT + "/contrib/packaging/wix/COPYING.rtf"), |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
246 |
path = "COPYING.rtf", |
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 |
manifest.remove("Copying.txt") |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
249 |
manifest.add_file( |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
250 |
FileContent(path = ROOT + "/contrib/win32/mercurial.ini"), |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
251 |
path = "defaultrc/mercurial.rc", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
252 |
) |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
253 |
manifest.add_file( |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
254 |
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
|
255 |
path = "defaultrc/editor.rc", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
256 |
) |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
257 |
|
47885
3962503cd1e8
pyoxidizer: add arch to PyOxidizer MSIs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47884
diff
changeset
|
258 |
wix = WiXInstaller( |
3962503cd1e8
pyoxidizer: add arch to PyOxidizer MSIs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47884
diff
changeset
|
259 |
"hg", |
3962503cd1e8
pyoxidizer: add arch to PyOxidizer MSIs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47884
diff
changeset
|
260 |
"%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
|
261 |
arch = platform, |
3962503cd1e8
pyoxidizer: add arch to PyOxidizer MSIs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47884
diff
changeset
|
262 |
) |
47205
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
263 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
264 |
# 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
|
265 |
wix.add_install_files(manifest) |
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 |
# From mercurial.wxs. |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
268 |
wix.install_files_root_directory_id = "INSTALLDIR" |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
269 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
270 |
# Pull in our custom .wxs files. |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
271 |
defines = { |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
272 |
"PyOxidizer": "1", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
273 |
"Platform": platform, |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
274 |
"Version": VERSION, |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
275 |
"Comments": "Installs Mercurial version %s" % VERSION, |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
276 |
"PythonVersion": "3", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
277 |
"MercurialHasLib": "1", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
278 |
} |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
279 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
280 |
if EXTRA_MSI_FEATURES: |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
281 |
defines["MercurialExtraFeatures"] = EXTRA_MSI_FEATURES |
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 |
wix.add_wxs_file( |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
284 |
ROOT + "/contrib/packaging/wix/mercurial.wxs", |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
285 |
preprocessor_parameters=defines, |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
286 |
) |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
287 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
288 |
# 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
|
289 |
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
|
290 |
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
|
291 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
292 |
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
|
293 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
294 |
return wix |
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
295 |
|
603efb3845ba
pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47204
diff
changeset
|
296 |
|
47206
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
297 |
def register_code_signers(): |
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
298 |
if not IS_WINDOWS: |
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
299 |
return |
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
300 |
|
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
301 |
if SIGNING_PFX_PATH: |
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
302 |
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
|
303 |
elif SIGNING_SUBJECT_NAME: |
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
304 |
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
|
305 |
else: |
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
306 |
signer = None |
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
307 |
|
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
308 |
if signer: |
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
309 |
signer.set_time_stamp_server(TIME_STAMP_SERVER_URL) |
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
310 |
signer.activate() |
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
311 |
|
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
312 |
|
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
313 |
register_code_signers() |
c8001d9c26f5
pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47205
diff
changeset
|
314 |
|
47203
9438e9b7321a
pyoxidizer: simplify targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47201
diff
changeset
|
315 |
register_target("distribution", make_distribution) |
9438e9b7321a
pyoxidizer: simplify targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47201
diff
changeset
|
316 |
register_target("exe", make_exe, depends = ["distribution"]) |
9438e9b7321a
pyoxidizer: simplify targets
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47201
diff
changeset
|
317 |
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
|
318 |
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
|
319 |
|
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
320 |
resolve_targets() |