annotate rust/hgcli/pyoxidizer.bzl @ 45134:487df3676d2c

status: match category text in the option description The ! category in the main status help text is defined as "missing", so use the same text for the help text of --delete. Differential Revision: https://phab.mercurial-scm.org/D8759
author Joerg Sonnenberger <joerg@bec.de>
date Thu, 16 Jul 2020 15:56:13 +0200
parents 118f067f6bd1
children 57b5452a55d5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
3 # Code to run in Python interpreter.
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
4 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
5
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
6 set_build_path(ROOT + "/build/pyoxidizer")
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 def make_distribution():
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
9 return default_python_distribution()
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
10
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
11 def make_distribution_windows():
44822
118f067f6bd1 pyoxidizer: formatting bazel definitions
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents: 44763
diff changeset
12 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
13
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
14 def make_exe(dist):
44822
118f067f6bd1 pyoxidizer: formatting bazel definitions
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents: 44763
diff changeset
15 """Builds a Rust-wrapped Mercurial binary."""
44639
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
16 config = PythonInterpreterConfig(
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
17 raw_allocator = "system",
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
18 run_eval = RUN_CODE,
44639
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
19 # We want to let the user load extensions from the file system
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
20 filesystem_importer = True,
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
21 # We need this to make resourceutil happy, since it looks for sys.frozen.
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
22 sys_frozen = True,
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
23 legacy_windows_stdio = True,
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24 )
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
25
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
26 exe = dist.to_python_executable(
44639
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
27 name = "hg",
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
28 resources_policy = "prefer-in-memory-fallback-filesystem-relative:lib",
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
29 config = config,
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
30 # Extension may depend on any Python functionality. Include all
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
31 # extensions.
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
32 extension_module_filter = "all",
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
33 )
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
35 # Add Mercurial to resources.
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
36 for resource in dist.pip_install(["--verbose", ROOT]):
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
37 # This is a bit wonky and worth explaining.
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
38 #
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
39 # Various parts of Mercurial don't yet support loading package
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
40 # resources via the ResourceReader interface. Or, not having
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
41 # file-based resources would be too inconvenient for users.
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
42 #
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
43 # So, for package resources, we package them both in the
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
44 # filesystem as well as in memory. If both are defined,
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
45 # PyOxidizer will prefer the in-memory location. So even
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
46 # if the filesystem file isn't packaged in the location
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
47 # specified here, we should never encounter an errors as the
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
48 # resource will always be available in memory.
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
49 if type(resource) == "PythonPackageResource":
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
50 exe.add_filesystem_relative_python_resource(".", resource)
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
51 exe.add_in_memory_python_resource(resource)
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
52 else:
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
53 exe.add_python_resource(resource)
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
54
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
55 # On Windows, we install extra packages for convenience.
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
56 if "windows" in BUILD_TARGET_TRIPLE:
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
57 exe.add_python_resources(
44822
118f067f6bd1 pyoxidizer: formatting bazel definitions
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents: 44763
diff changeset
58 dist.pip_install(["-r", ROOT + "/contrib/packaging/requirements_win32.txt"]),
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
59 )
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60
44639
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
61 return exe
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
62
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
63 def make_manifest(dist, exe):
44639
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
64 m = FileManifest()
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44638
diff changeset
65 m.add_python_resource(".", exe)
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
66
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
67 return m
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
68
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
69 def make_embedded_resources(exe):
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
70 return exe.to_embedded_resources()
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
71
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
72 register_target("distribution_posix", make_distribution)
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
73 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
74
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
75 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
76 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
77
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
78 register_target(
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
79 "app_posix",
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
80 make_manifest,
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
81 depends = ["distribution_posix", "exe_posix"],
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
82 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
83 )
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
84 register_target(
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
85 "app_windows",
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
86 make_manifest,
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
87 depends = ["distribution_windows", "exe_windows"],
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
88 default = "windows" in BUILD_TARGET_TRIPLE,
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
89 )
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
90
44638
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
91 resolve_targets()
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
92
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
93 # END OF COMMON USER-ADJUSTED SETTINGS.
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
94 #
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
95 # 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
96 # to be updated by people.
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
97
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44639
diff changeset
98 PYOXIDIZER_VERSION = "0.7.0"