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