Mercurial > hg
annotate contrib/packaging/hgpackaging/pyoxidizer.py @ 50916:98b8836d0e82
hgweb: use sysstr to set attribute on diff option
Attribute identifier should be `str` not `bytes`.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 01 Sep 2023 12:09:54 +0200 |
parents | 8d7eaff92f9c |
children |
rev | line source |
---|---|
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # pyoxidizer.py - Packaging support for PyOxidizer |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 # |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2020 Gregory Szorc <gregory.szorc@gmail.com> |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 # |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 # no-check-code because Python 3 native. |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 import os |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 import pathlib |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 import shutil |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 import subprocess |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 import sys |
47210
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
15 import typing |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 from .downloads import download_entry |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 from .util import ( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 extract_zip_to_directory, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 process_install_rules, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 find_vc_runtime_dll, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
22 ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
23 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 STAGING_RULES_WINDOWS = [ |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 ('contrib/hgk', 'contrib/hgk.tcl'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
27 ('contrib/hgweb.fcgi', 'contrib/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
28 ('contrib/hgweb.wsgi', 'contrib/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 ('contrib/logo-droplets.svg', 'contrib/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 ('contrib/mercurial.el', 'contrib/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 ('contrib/mq.el', 'contrib/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 ('contrib/tcsh_completion', 'contrib/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 ('contrib/tcsh_completion_build.sh', 'contrib/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 ('contrib/vim/*', 'contrib/vim/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 ('contrib/win32/postinstall.txt', 'ReleaseNotes.txt'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 ('contrib/win32/ReadMe.html', 'ReadMe.html'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 ('contrib/xml.rnc', 'contrib/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 ('doc/*.html', 'doc/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 ('doc/style.css', 'doc/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 ('COPYING', 'Copying.txt'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 ] |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 STAGING_RULES_APP = [ |
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
44 ('lib/mercurial/helptext/**/*.txt', 'helptext/'), |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
45 ('lib/mercurial/defaultrc/*.rc', 'defaultrc/'), |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
46 ('lib/mercurial/locale/**/*', 'locale/'), |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
47 ('lib/mercurial/templates/**/*', 'templates/'), |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
48 ] |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
50 STAGING_EXCLUDES_WINDOWS = [ |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
51 "doc/hg-ssh.8.html", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
52 ] |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
53 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
54 |
47207
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
55 def build_docs_html(source_dir: pathlib.Path): |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
56 """Ensures HTML documentation is built. |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
57 |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
58 This will fail if docutils isn't available. |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
59 |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
60 (The HTML docs aren't built as part of `pip install` so we need to build them |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
61 out of band.) |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
62 """ |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
63 subprocess.run( |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
64 [sys.executable, str(source_dir / "setup.py"), "build_doc", "--html"], |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
65 cwd=str(source_dir), |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
66 check=True, |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
67 ) |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
68 |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
69 |
47209
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
70 def run_pyoxidizer( |
47210
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
71 source_dir: pathlib.Path, |
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
72 build_dir: pathlib.Path, |
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
73 target_triple: str, |
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
74 build_vars: typing.Optional[typing.Dict[str, str]] = None, |
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
75 target: typing.Optional[str] = None, |
47209
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
76 ) -> pathlib.Path: |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
77 """Run `pyoxidizer` in an environment with access to build dependencies. |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
78 |
47209
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
79 Returns the output directory that pyoxidizer would have used for build |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
80 artifacts. Actual build artifacts are likely in a sub-directory with the |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
81 name of the pyoxidizer build target that was built. |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
82 """ |
47210
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
83 build_vars = build_vars or {} |
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
84 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
85 # We need to make gettext binaries available for compiling i18n files. |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
86 gettext_pkg, gettext_entry = download_entry('gettext', build_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
87 gettext_dep_pkg = download_entry('gettext-dep', build_dir)[0] |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
88 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
89 gettext_root = build_dir / ('gettext-win-%s' % gettext_entry['version']) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
91 if not gettext_root.exists(): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
92 extract_zip_to_directory(gettext_pkg, gettext_root) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
93 extract_zip_to_directory(gettext_dep_pkg, gettext_root) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
94 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
95 env = dict(os.environ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 env["PATH"] = "%s%s%s" % ( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 env["PATH"], |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 os.pathsep, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
99 str(gettext_root / "bin"), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
102 args = [ |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 "pyoxidizer", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
104 "build", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
105 "--path", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
106 str(source_dir / "rust" / "hgcli"), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
107 "--release", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
108 "--target-triple", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
109 target_triple, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
110 ] |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
111 |
47210
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
112 for k, v in sorted(build_vars.items()): |
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
113 args.extend(["--var", k, v]) |
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
114 |
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
115 if target: |
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
116 args.append(target) |
73f1a10320d1
packaging: use PyOxidizer for producing WiX MSI installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47209
diff
changeset
|
117 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
118 subprocess.run(args, env=env, check=True) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
119 |
47209
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
120 return source_dir / "build" / "pyoxidizer" / target_triple / "release" |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
121 |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
122 |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
123 def create_pyoxidizer_install_layout( |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
124 source_dir: pathlib.Path, |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
125 build_dir: pathlib.Path, |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
126 out_dir: pathlib.Path, |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
127 target_triple: str, |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
128 ): |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
129 """Build Mercurial with PyOxidizer and copy additional files into place. |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
130 |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
131 After successful completion, ``out_dir`` contains files constituting a |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
132 Mercurial install. |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
133 """ |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
134 |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
135 run_pyoxidizer(source_dir, build_dir, target_triple) |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
136 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
137 build_dir = ( |
47882
1e6cb23ce6da
packaging: reference proper output directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47210
diff
changeset
|
138 source_dir / "build" / "pyoxidizer" / target_triple / "release" / "app" |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
139 ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
140 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
141 if out_dir.exists(): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
142 print("purging %s" % out_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
143 shutil.rmtree(out_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
144 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
145 # Now assemble all the files from PyOxidizer into the staging directory. |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
146 shutil.copytree(build_dir, out_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
147 |
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
148 # Move some of those files around. We can get rid of this once Mercurial |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
149 # is taught to use the importlib APIs for reading resources. |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
150 process_install_rules(STAGING_RULES_APP, build_dir, out_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
151 |
47207
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
152 build_docs_html(source_dir) |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
153 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
154 if "windows" in target_triple: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
155 process_install_rules(STAGING_RULES_WINDOWS, source_dir, out_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
156 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
157 # Write out a default editor.rc file to configure notepad as the |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
158 # default editor. |
45922
37bcd7f5a543
pyoxidizer: make sure defaultrc directory exists before trying to write to it
Augie Fackler <augie@google.com>
parents:
45685
diff
changeset
|
159 os.makedirs(out_dir / "defaultrc", exist_ok=True) |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
160 with (out_dir / "defaultrc" / "editor.rc").open( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
161 "w", encoding="utf-8" |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
162 ) as fh: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
163 fh.write("[ui]\neditor = notepad\n") |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
164 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
165 for f in STAGING_EXCLUDES_WINDOWS: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
166 p = out_dir / f |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
167 if p.exists(): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
168 print("removing %s" % p) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
169 p.unlink() |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
170 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
171 # Add vcruntimeXXX.dll next to executable. |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
172 vc_runtime_dll = find_vc_runtime_dll(x64="x86_64" in target_triple) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
173 shutil.copy(vc_runtime_dll, out_dir / vc_runtime_dll.name) |