##// END OF EJS Templates
pyoxidizer: formatting bazel definitions...
Rodrigo Damazio Bovendorp -
r45339:118f067f default
parent child Browse files
Show More
@@ -1,104 +1,98 b''
1 1 ROOT = CWD + "/../.."
2 2
3 3 # Code to run in Python interpreter.
4 4 RUN_CODE = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()"
5 5
6
7 6 set_build_path(ROOT + "/build/pyoxidizer")
8 7
9
10 8 def make_distribution():
11 9 return default_python_distribution()
12 10
13
14 11 def make_distribution_windows():
15 return default_python_distribution(flavor="standalone_dynamic")
16
12 return default_python_distribution(flavor = "standalone_dynamic")
17 13
18 14 def make_exe(dist):
15 """Builds a Rust-wrapped Mercurial binary."""
19 16 config = PythonInterpreterConfig(
20 17 raw_allocator = "system",
21 18 run_eval = RUN_CODE,
22 19 # We want to let the user load extensions from the file system
23 20 filesystem_importer = True,
24 21 # We need this to make resourceutil happy, since it looks for sys.frozen.
25 22 sys_frozen = True,
26 23 legacy_windows_stdio = True,
27 24 )
28 25
29 26 exe = dist.to_python_executable(
30 27 name = "hg",
31 28 resources_policy = "prefer-in-memory-fallback-filesystem-relative:lib",
32 29 config = config,
33 30 # Extension may depend on any Python functionality. Include all
34 31 # extensions.
35 32 extension_module_filter = "all",
36 33 )
37 34
38 35 # Add Mercurial to resources.
39 36 for resource in dist.pip_install(["--verbose", ROOT]):
40 37 # This is a bit wonky and worth explaining.
41 38 #
42 39 # Various parts of Mercurial don't yet support loading package
43 40 # resources via the ResourceReader interface. Or, not having
44 41 # file-based resources would be too inconvenient for users.
45 42 #
46 43 # So, for package resources, we package them both in the
47 44 # filesystem as well as in memory. If both are defined,
48 45 # PyOxidizer will prefer the in-memory location. So even
49 46 # if the filesystem file isn't packaged in the location
50 47 # specified here, we should never encounter an errors as the
51 48 # resource will always be available in memory.
52 49 if type(resource) == "PythonPackageResource":
53 50 exe.add_filesystem_relative_python_resource(".", resource)
54 51 exe.add_in_memory_python_resource(resource)
55 52 else:
56 53 exe.add_python_resource(resource)
57 54
58 55 # On Windows, we install extra packages for convenience.
59 56 if "windows" in BUILD_TARGET_TRIPLE:
60 57 exe.add_python_resources(
61 dist.pip_install(["-r", ROOT + "/contrib/packaging/requirements_win32.txt"])
58 dist.pip_install(["-r", ROOT + "/contrib/packaging/requirements_win32.txt"]),
62 59 )
63 60
64 61 return exe
65 62
66
67 63 def make_manifest(dist, exe):
68 64 m = FileManifest()
69 65 m.add_python_resource(".", exe)
70 66
71 67 return m
72 68
73
74 69 def make_embedded_resources(exe):
75 70 return exe.to_embedded_resources()
76 71
77
78 72 register_target("distribution_posix", make_distribution)
79 73 register_target("distribution_windows", make_distribution_windows)
80 74
81 75 register_target("exe_posix", make_exe, depends = ["distribution_posix"])
82 76 register_target("exe_windows", make_exe, depends = ["distribution_windows"])
83 77
84 78 register_target(
85 79 "app_posix",
86 80 make_manifest,
87 81 depends = ["distribution_posix", "exe_posix"],
88 82 default = "windows" not in BUILD_TARGET_TRIPLE,
89 83 )
90 84 register_target(
91 85 "app_windows",
92 86 make_manifest,
93 87 depends = ["distribution_windows", "exe_windows"],
94 88 default = "windows" in BUILD_TARGET_TRIPLE,
95 89 )
96 90
97 91 resolve_targets()
98 92
99 93 # END OF COMMON USER-ADJUSTED SETTINGS.
100 94 #
101 95 # Everything below this is typically managed by PyOxidizer and doesn't need
102 96 # to be updated by people.
103 97
104 98 PYOXIDIZER_VERSION = "0.7.0"
General Comments 0
You need to be logged in to leave comments. Login now