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