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