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