Show More
@@ -1,87 +1,87 b'' | |||||
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(python_version = "3.8") |
|
11 | return default_python_distribution(python_version = "3.8") | |
12 |
|
12 | |||
13 | def resource_callback(policy, resource): |
|
13 | def resource_callback(policy, resource): | |
14 | if not IS_WINDOWS: |
|
14 | if not IS_WINDOWS: | |
15 | resource.add_location = "in-memory" |
|
15 | resource.add_location = "in-memory" | |
16 | return |
|
16 | return | |
17 |
|
17 | |||
18 | # We use a custom resource routing policy to influence where things are loaded |
|
18 | # We use a custom resource routing policy to influence where things are loaded | |
19 | # from. |
|
19 | # from. | |
20 | # |
|
20 | # | |
21 | # For Python modules and resources, we load from memory if they are in |
|
21 | # For Python modules and resources, we load from memory if they are in | |
22 | # the standard library and from the filesystem if not. This is because |
|
22 | # the standard library and from the filesystem if not. This is because | |
23 | # parts of Mercurial and some 3rd party packages aren't yet compatible |
|
23 | # parts of Mercurial and some 3rd party packages aren't yet compatible | |
24 | # with memory loading. |
|
24 | # with memory loading. | |
25 | # |
|
25 | # | |
26 | # For Python extension modules, we load from the filesystem because |
|
26 | # For Python extension modules, we load from the filesystem because | |
27 | # this yields greatest compatibility. |
|
27 | # this yields greatest compatibility. | |
28 | if type(resource) in ("PythonModuleSource", "PythonPackageResource", "PythonPackageDistributionResource"): |
|
28 | if type(resource) in ("PythonModuleSource", "PythonPackageResource", "PythonPackageDistributionResource"): | |
29 | if resource.is_stdlib: |
|
29 | if resource.is_stdlib: | |
30 | resource.add_location = "in-memory" |
|
30 | resource.add_location = "in-memory" | |
31 | else: |
|
31 | else: | |
32 | resource.add_location = "filesystem-relative:lib" |
|
32 | resource.add_location = "filesystem-relative:lib" | |
33 |
|
33 | |||
34 | elif type(resource) == "PythonExtensionModule": |
|
34 | elif type(resource) == "PythonExtensionModule": | |
35 | resource.add_location = "filesystem-relative:lib" |
|
35 | resource.add_location = "filesystem-relative:lib" | |
36 |
|
36 | |||
37 | def make_exe(dist): |
|
37 | def make_exe(dist): | |
38 | """Builds a Rust-wrapped Mercurial binary.""" |
|
38 | """Builds a Rust-wrapped Mercurial binary.""" | |
39 | packaging_policy = dist.make_python_packaging_policy() |
|
39 | packaging_policy = dist.make_python_packaging_policy() | |
40 |
|
40 | |||
41 | # Extension may depend on any Python functionality. Include all |
|
41 | # Extension may depend on any Python functionality. Include all | |
42 | # extensions. |
|
42 | # extensions. | |
43 | packaging_policy.extension_module_filter = "all" |
|
43 | packaging_policy.extension_module_filter = "all" | |
44 | packaging_policy.resources_location = "in-memory" |
|
44 | packaging_policy.resources_location = "in-memory" | |
45 | if IS_WINDOWS: |
|
45 | if IS_WINDOWS: | |
46 | packaging_policy.resources_location_fallback = "filesystem-relative:lib" |
|
46 | packaging_policy.resources_location_fallback = "filesystem-relative:lib" | |
47 | packaging_policy.register_resource_callback(resource_callback) |
|
47 | packaging_policy.register_resource_callback(resource_callback) | |
48 |
|
48 | |||
49 | config = dist.make_python_interpreter_config() |
|
49 | config = dist.make_python_interpreter_config() | |
50 |
config. |
|
50 | config.allocator_backend = "default" | |
51 | config.run_command = RUN_CODE |
|
51 | config.run_command = RUN_CODE | |
52 |
|
52 | |||
53 | # We want to let the user load extensions from the file system |
|
53 | # We want to let the user load extensions from the file system | |
54 | config.filesystem_importer = True |
|
54 | config.filesystem_importer = True | |
55 |
|
55 | |||
56 | # We need this to make resourceutil happy, since it looks for sys.frozen. |
|
56 | # We need this to make resourceutil happy, since it looks for sys.frozen. | |
57 | config.sys_frozen = True |
|
57 | config.sys_frozen = True | |
58 | config.legacy_windows_stdio = True |
|
58 | config.legacy_windows_stdio = True | |
59 |
|
59 | |||
60 | exe = dist.to_python_executable( |
|
60 | exe = dist.to_python_executable( | |
61 | name = "hg", |
|
61 | name = "hg", | |
62 | packaging_policy = packaging_policy, |
|
62 | packaging_policy = packaging_policy, | |
63 | config = config, |
|
63 | config = config, | |
64 | ) |
|
64 | ) | |
65 |
|
65 | |||
66 | # Add Mercurial to resources. |
|
66 | # Add Mercurial to resources. | |
67 | exe.add_python_resources(exe.pip_install(["--verbose", ROOT])) |
|
67 | exe.add_python_resources(exe.pip_install(["--verbose", ROOT])) | |
68 |
|
68 | |||
69 | # On Windows, we install extra packages for convenience. |
|
69 | # On Windows, we install extra packages for convenience. | |
70 | if IS_WINDOWS: |
|
70 | if IS_WINDOWS: | |
71 | exe.add_python_resources( |
|
71 | exe.add_python_resources( | |
72 | exe.pip_install(["-r", ROOT + "/contrib/packaging/requirements-windows-py3.txt"]), |
|
72 | exe.pip_install(["-r", ROOT + "/contrib/packaging/requirements-windows-py3.txt"]), | |
73 | ) |
|
73 | ) | |
74 |
|
74 | |||
75 | return exe |
|
75 | return exe | |
76 |
|
76 | |||
77 | def make_manifest(dist, exe): |
|
77 | def make_manifest(dist, exe): | |
78 | m = FileManifest() |
|
78 | m = FileManifest() | |
79 | m.add_python_resource(".", exe) |
|
79 | m.add_python_resource(".", exe) | |
80 |
|
80 | |||
81 | return m |
|
81 | return m | |
82 |
|
82 | |||
83 | register_target("distribution", make_distribution) |
|
83 | register_target("distribution", make_distribution) | |
84 | register_target("exe", make_exe, depends = ["distribution"]) |
|
84 | register_target("exe", make_exe, depends = ["distribution"]) | |
85 | register_target("app", make_manifest, depends = ["distribution", "exe"], default = True) |
|
85 | register_target("app", make_manifest, depends = ["distribution", "exe"], default = True) | |
86 |
|
86 | |||
87 | resolve_targets() |
|
87 | resolve_targets() |
General Comments 0
You need to be logged in to leave comments.
Login now