##// END OF EJS Templates
pyoxidizer: run buildifier...
Augie Fackler -
r46491:5d73d305 default
parent child Browse files
Show More
@@ -1,112 +1,116
1 1 ROOT = CWD + "/../.."
2 2
3 3 IS_WINDOWS = "windows" in BUILD_TARGET_TRIPLE
4 4
5 5 # Code to run in Python interpreter.
6 6 RUN_CODE = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()"
7 7
8 8 set_build_path(ROOT + "/build/pyoxidizer")
9 9
10 10 def make_distribution():
11 11 return default_python_distribution()
12 12
13 13 def make_distribution_windows():
14 14 return default_python_distribution(flavor = "standalone_dynamic")
15 15
16 16 def resource_callback(policy, resource):
17 17 if not IS_WINDOWS:
18 18 resource.add_location = "in-memory"
19 19 return
20
20 21 # We use a custom resource routing policy to influence where things are loaded
21 22 # from.
22 23 #
23 24 # For Python modules and resources, we load from memory if they are in
24 25 # the standard library and from the filesystem if not. This is because
25 26 # parts of Mercurial and some 3rd party packages aren't yet compatible
26 27 # with memory loading.
27 28 #
28 29 # For Python extension modules, we load from the filesystem because
29 30 # this yields greatest compatibility.
30 31 if type(resource) in ("PythonModuleSource", "PythonPackageResource", "PythonPackageDistributionResource"):
31 32 if resource.is_stdlib:
32 33 resource.add_location = "in-memory"
33 34 else:
34 35 resource.add_location = "filesystem-relative:lib"
35 36
36 37 elif type(resource) == "PythonExtensionModule":
37 38 resource.add_location = "filesystem-relative:lib"
38 39
39 40 def make_exe(dist):
40 41 """Builds a Rust-wrapped Mercurial binary."""
41 42 packaging_policy = dist.make_python_packaging_policy()
43
42 44 # Extension may depend on any Python functionality. Include all
43 45 # extensions.
44 46 packaging_policy.extension_module_filter = "all"
45 47 packaging_policy.resources_location = "in-memory"
46 48 if IS_WINDOWS:
47 49 packaging_policy.resources_location_fallback = "filesystem-relative:lib"
48 50 packaging_policy.register_resource_callback(resource_callback)
49 51
50 52 config = dist.make_python_interpreter_config()
51 53 config.raw_allocator = "system"
52 54 config.run_command = RUN_CODE
55
53 56 # We want to let the user load extensions from the file system
54 57 config.filesystem_importer = True
58
55 59 # We need this to make resourceutil happy, since it looks for sys.frozen.
56 60 config.sys_frozen = True
57 61 config.legacy_windows_stdio = True
58 62
59 63 exe = dist.to_python_executable(
60 64 name = "hg",
61 65 packaging_policy = packaging_policy,
62 66 config = config,
63 67 )
64 68
65 69 # Add Mercurial to resources.
66 70 exe.add_python_resources(exe.pip_install(["--verbose", ROOT]))
67 71
68 72 # On Windows, we install extra packages for convenience.
69 73 if IS_WINDOWS:
70 74 exe.add_python_resources(
71 75 exe.pip_install(["-r", ROOT + "/contrib/packaging/requirements-windows-py2.txt"]),
72 76 )
73 77
74 78 return exe
75 79
76 80 def make_manifest(dist, exe):
77 81 m = FileManifest()
78 82 m.add_python_resource(".", exe)
79 83
80 84 return m
81 85
82 86 def make_embedded_resources(exe):
83 87 return exe.to_embedded_resources()
84 88
85 89 register_target("distribution_posix", make_distribution)
86 90 register_target("distribution_windows", make_distribution_windows)
87 91
88 92 register_target("exe_posix", make_exe, depends = ["distribution_posix"])
89 93 register_target("exe_windows", make_exe, depends = ["distribution_windows"])
90 94
91 95 register_target(
92 96 "app_posix",
93 97 make_manifest,
94 98 depends = ["distribution_posix", "exe_posix"],
95 99 default = "windows" not in BUILD_TARGET_TRIPLE,
96 100 )
97 101 register_target(
98 102 "app_windows",
99 103 make_manifest,
100 104 depends = ["distribution_windows", "exe_windows"],
101 105 default = "windows" in BUILD_TARGET_TRIPLE,
102 106 )
103 107
104 108 resolve_targets()
105 109
106 110 # END OF COMMON USER-ADJUSTED SETTINGS.
107 111 #
108 112 # Everything below this is typically managed by PyOxidizer and doesn't need
109 113 # to be updated by people.
110 114
111 115 PYOXIDIZER_VERSION = "0.9.0"
112 116 PYOXIDIZER_COMMIT = "1fbc264cc004226cd76ee452e0a386ffca6ccfb1"
General Comments 0
You need to be logged in to leave comments. Login now