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