Mercurial > hg
annotate rust/hgcli/pyoxidizer.bzl @ 45752:d270b9b797a7 stable
contrib: split Windows requirements into multiple files
Package support for Python 2 has diverged significantly. It is no
longer trivial to maintain a single requirements file that supports
both Python 2 and 3 because the set of packages and versions varies
wildly.
This commit split up the Windows requirements files so we have
variants for Python 2 and 3. As part of this, I also renamed the
files to have what I believe to be more reasonable naming ("win32"
felt like a weird identifier to me).
We can see that some package versions decreated on 2.7. This is
because the old pinned versions weren't compatible with Python 2.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 21 Oct 2020 21:53:19 -0700 |
parents | f95b16796688 |
children | f14c33b2e497 cd7f36337741 |
rev | line source |
---|---|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
1 ROOT = CWD + "/../.." |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
3 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
|
4 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
5 # Code to run in Python interpreter. |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
6 RUN_CODE = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()" |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
7 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
8 set_build_path(ROOT + "/build/pyoxidizer") |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
9 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
10 def make_distribution(): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
11 return default_python_distribution() |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
12 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
13 def make_distribution_windows(): |
44822
118f067f6bd1
pyoxidizer: formatting bazel definitions
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44763
diff
changeset
|
14 return default_python_distribution(flavor = "standalone_dynamic") |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
15 |
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
16 def resource_callback(policy, resource): |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
17 # 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
|
18 # from. |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
19 # |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
20 # 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
|
21 # 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
|
22 # 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
|
23 # with memory loading. |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
24 # |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
25 # 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
|
26 # this yields greatest compatibility. |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
27 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
|
28 if resource.is_stdlib: |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
29 resource.add_location = "in-memory" |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
30 else: |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
31 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
|
32 |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
33 elif type(resource) == "PythonExtensionModule": |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
34 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
|
35 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
36 def make_exe(dist): |
44822
118f067f6bd1
pyoxidizer: formatting bazel definitions
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44763
diff
changeset
|
37 """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
|
38 packaging_policy = dist.make_python_packaging_policy() |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
39 # 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
|
40 # extensions. |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
41 packaging_policy.extension_module_filter = "all" |
45749
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
42 packaging_policy.resources_location = "in-memory" |
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
43 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
|
44 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
|
45 |
45749
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
46 config = dist.make_python_interpreter_config() |
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
47 config.raw_allocator = "system" |
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
48 config.run_mode = "eval:%s" % RUN_CODE |
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
49 # 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
|
50 config.filesystem_importer = True |
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
51 # 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
|
52 config.sys_frozen = True |
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
53 config.legacy_windows_stdio = True |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
54 |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
55 exe = dist.to_python_executable( |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
56 name = "hg", |
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
57 packaging_policy = packaging_policy, |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
58 config = config, |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
59 ) |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
60 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
61 # Add Mercurial to resources. |
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44822
diff
changeset
|
62 exe.add_python_resources(exe.pip_install(["--verbose", ROOT])) |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
63 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
64 # 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
|
65 if IS_WINDOWS: |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
66 exe.add_python_resources( |
45752
d270b9b797a7
contrib: split Windows requirements into multiple files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45749
diff
changeset
|
67 exe.pip_install(["-r", ROOT + "/contrib/packaging/requirements-windows-py2.txt"]), |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
68 ) |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
69 |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
70 return exe |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
71 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
72 def make_manifest(dist, exe): |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
73 m = FileManifest() |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
74 m.add_python_resource(".", exe) |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
75 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
76 return m |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
77 |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
78 def make_embedded_resources(exe): |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
79 return exe.to_embedded_resources() |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
80 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
81 register_target("distribution_posix", make_distribution) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
82 register_target("distribution_windows", make_distribution_windows) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
83 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
84 register_target("exe_posix", make_exe, depends = ["distribution_posix"]) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
85 register_target("exe_windows", make_exe, depends = ["distribution_windows"]) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
86 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
87 register_target( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
88 "app_posix", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
89 make_manifest, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
90 depends = ["distribution_posix", "exe_posix"], |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
91 default = "windows" not in BUILD_TARGET_TRIPLE, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
92 ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
93 register_target( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
94 "app_windows", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
95 make_manifest, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
96 depends = ["distribution_windows", "exe_windows"], |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
97 default = "windows" in BUILD_TARGET_TRIPLE, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
98 ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44639
diff
changeset
|
99 |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 resolve_targets() |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
102 # END OF COMMON USER-ADJUSTED SETTINGS. |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 # |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
104 # Everything below this is typically managed by PyOxidizer and doesn't need |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
105 # to be updated by people. |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
106 |
45749
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
107 PYOXIDIZER_VERSION = "0.9.0" |
f95b16796688
pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45685
diff
changeset
|
108 PYOXIDIZER_COMMIT = "1fbc264cc004226cd76ee452e0a386ffca6ccfb1" |