author | Pulkit Goyal <7895pulkit@gmail.com> |
Thu, 16 Apr 2020 22:51:09 +0530 | |
branch | stable |
changeset 44729 | 26ce8e751503 |
parent 44639 | bc847878f4c0 |
child 44763 | 94f4f2ec7dee |
permissions | -rw-r--r-- |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
1 |
ROOT = CWD + "/../.." |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
3 |
def make_exe(): |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
4 |
dist = default_python_distribution() |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
5 |
|
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
6 |
code = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()" |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
8 |
config = PythonInterpreterConfig( |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
9 |
raw_allocator = "system", |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
10 |
run_eval = code, |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
11 |
# We want to let the user load extensions from the file system |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
12 |
filesystem_importer = True, |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
13 |
# We need this to make resourceutil happy, since it looks for sys.frozen. |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
14 |
sys_frozen = True, |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
15 |
legacy_windows_stdio = True, |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 |
) |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 |
|
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 |
exe = dist.to_python_executable( |
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
19 |
name = "hg", |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
20 |
resources_policy = "prefer-in-memory-fallback-filesystem-relative:lib", |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
21 |
config = config, |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
22 |
# Extension may depend on any Python functionality. Include all |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
23 |
# extensions. |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 |
extension_module_filter = "all", |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 |
) |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 |
|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
27 |
exe.add_python_resources(dist.pip_install([ROOT])) |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
28 |
|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
29 |
return exe |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
30 |
|
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
31 |
def make_install(exe): |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
32 |
m = FileManifest() |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 |
|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
34 |
# `hg` goes in root directory. |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
35 |
m.add_python_resource(".", exe) |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 |
|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
37 |
templates = glob( |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
38 |
include = [ROOT + "/mercurial/templates/**/*"], |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
39 |
strip_prefix = ROOT + "/mercurial/", |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
40 |
) |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
41 |
m.add_manifest(templates) |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 |
|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
43 |
return m |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 |
|
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 |
def make_embedded_resources(exe): |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 |
return exe.to_embedded_resources() |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 |
|
44639
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
48 |
register_target("exe", make_exe) |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
49 |
register_target("app", make_install, depends = ["exe"], default = True) |
bc847878f4c0
hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44638
diff
changeset
|
50 |
register_target("embedded", make_embedded_resources, depends = ["exe"], default_build_script = True) |
44638
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
51 |
resolve_targets() |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
52 |
|
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
53 |
# END OF COMMON USER-ADJUSTED SETTINGS. |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
54 |
# |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
55 |
# Everything below this is typically managed by PyOxidizer and doesn't need |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
56 |
# to be updated by people. |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
57 |
|
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
58 |
PYOXIDIZER_VERSION = "0.7.0-pre" |
af739894a4c1
hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
59 |
PYOXIDIZER_COMMIT = "c772a1379c3026314eda1c8ea244b86c0658951d" |