##// END OF EJS Templates
pyoxidizer: allow extensions to be loaded from the file system...
Martin von Zweigbergk -
r44868:6689ceba default
parent child Browse files
Show More
@@ -1,58 +1,60 b''
1 # Instructions:
1 # Instructions:
2 #
2 #
3 # 1. cargo install --version 0.5.0 pyoxidizer
3 # 1. cargo install --version 0.5.0 pyoxidizer
4 # 2. cd /path/to/hg
4 # 2. cd /path/to/hg
5 # 3. pyoxidizer build --path contrib/packaging [--release]
5 # 3. pyoxidizer build --path contrib/packaging [--release]
6 # 4. Run build/pyoxidizer/<arch>/<debug|release>/app/hg
6 # 4. Run build/pyoxidizer/<arch>/<debug|release>/app/hg
7 #
7 #
8 # If you need to build again, you need to remove the build/lib.* and
8 # If you need to build again, you need to remove the build/lib.* and
9 # build/temp.* directories, otherwise PyOxidizer fails to pick up C
9 # build/temp.* directories, otherwise PyOxidizer fails to pick up C
10 # extensions. This is a bug in PyOxidizer.
10 # extensions. This is a bug in PyOxidizer.
11
11
12 ROOT = CWD + "/../.."
12 ROOT = CWD + "/../.."
13
13
14 set_build_path(ROOT + "/build/pyoxidizer")
14 set_build_path(ROOT + "/build/pyoxidizer")
15
15
16 def make_exe():
16 def make_exe():
17 dist = default_python_distribution()
17 dist = default_python_distribution()
18
18
19 code = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()"
19 code = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()"
20
20
21 config = PythonInterpreterConfig(
21 config = PythonInterpreterConfig(
22 raw_allocator = "system",
22 raw_allocator = "system",
23 run_eval = code,
23 run_eval = code,
24 # We want to let the user load extensions from the file system
25 filesystem_importer = True,
24 # We need this to make resourceutil happy, since it looks for sys.frozen.
26 # We need this to make resourceutil happy, since it looks for sys.frozen.
25 sys_frozen = True,
27 sys_frozen = True,
26 legacy_windows_stdio = True,
28 legacy_windows_stdio = True,
27 )
29 )
28
30
29 exe = dist.to_python_executable(
31 exe = dist.to_python_executable(
30 name = "hg",
32 name = "hg",
31 config = config,
33 config = config,
32 )
34 )
33
35
34 # Use setup.py install to build Mercurial and collect Python resources to
36 # Use setup.py install to build Mercurial and collect Python resources to
35 # embed in the executable.
37 # embed in the executable.
36 resources = dist.setup_py_install(ROOT)
38 resources = dist.setup_py_install(ROOT)
37 exe.add_python_resources(resources)
39 exe.add_python_resources(resources)
38
40
39 return exe
41 return exe
40
42
41 def make_install(exe):
43 def make_install(exe):
42 m = FileManifest()
44 m = FileManifest()
43
45
44 # `hg` goes in root directory.
46 # `hg` goes in root directory.
45 m.add_python_resource(".", exe)
47 m.add_python_resource(".", exe)
46
48
47 templates = glob(
49 templates = glob(
48 include=[ROOT + "/mercurial/templates/**/*"],
50 include=[ROOT + "/mercurial/templates/**/*"],
49 strip_prefix = ROOT + "/mercurial/",
51 strip_prefix = ROOT + "/mercurial/",
50 )
52 )
51 m.add_manifest(templates)
53 m.add_manifest(templates)
52
54
53 return m
55 return m
54
56
55 register_target("exe", make_exe)
57 register_target("exe", make_exe)
56 register_target("app", make_install, depends = ["exe"], default = True)
58 register_target("app", make_install, depends = ["exe"], default = True)
57
59
58 resolve_targets()
60 resolve_targets()
General Comments 0
You need to be logged in to leave comments. Login now