Mercurial > hg
annotate contrib/packaging/hgpackaging/pyoxidizer.py @ 47209:d09b36f69180
packaging: extract invocation of pyoxidizer to own function
I'll be refactoring how the WiX installer creation calls into
pyoxidizer and will need a lower level function for facilitating
that.
The new `run_pyoxidizer()` builds our execution environment
(with gettext available) and invokes `pyoxidizer`.
Differential Revision: https://phab.mercurial-scm.org/D10687
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 06 May 2021 16:07:01 -0700 |
parents | df1767fa822d |
children | 73f1a10320d1 |
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 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 from .downloads import download_entry |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 from .util import ( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 extract_zip_to_directory, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 process_install_rules, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 find_vc_runtime_dll, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 ) |
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 STAGING_RULES_WINDOWS = [ |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 ('contrib/bash_completion', 'contrib/'), |
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 ('contrib/zsh_completion', 'contrib/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 ('doc/*.html', 'doc/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 ('doc/style.css', 'doc/'), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 ('COPYING', 'Copying.txt'), |
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 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 STAGING_RULES_APP = [ |
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
45 ('lib/mercurial/helptext/**/*.txt', 'helptext/'), |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
46 ('lib/mercurial/defaultrc/*.rc', 'defaultrc/'), |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
47 ('lib/mercurial/locale/**/*', 'locale/'), |
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
48 ('lib/mercurial/templates/**/*', 'templates/'), |
44763
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 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
51 STAGING_EXCLUDES_WINDOWS = [ |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
52 "doc/hg-ssh.8.html", |
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 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
55 |
47207
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
56 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
|
57 """Ensures HTML documentation is built. |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
58 |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
59 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
|
60 |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
61 (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
|
62 out of band.) |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
63 """ |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
64 subprocess.run( |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
65 [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
|
66 cwd=str(source_dir), |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
67 check=True, |
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 |
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
70 |
47209
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
71 def run_pyoxidizer( |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
72 source_dir: pathlib.Path, build_dir: pathlib.Path, target_triple: str, |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
73 ) -> pathlib.Path: |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
74 """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
|
75 |
47209
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
76 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
|
77 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
|
78 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
|
79 """ |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
80 # 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
|
81 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
|
82 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
|
83 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
84 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
|
85 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
86 if not gettext_root.exists(): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
87 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
|
88 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
|
89 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 env = dict(os.environ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
91 env["PATH"] = "%s%s%s" % ( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
92 env["PATH"], |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
93 os.pathsep, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
94 str(gettext_root / "bin"), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
95 ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 args = [ |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 "pyoxidizer", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
99 "build", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 "--path", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 str(source_dir / "rust" / "hgcli"), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
102 "--release", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 "--target-triple", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
104 target_triple, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
105 ] |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
106 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
107 subprocess.run(args, env=env, check=True) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
108 |
47209
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
109 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
|
110 |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
111 |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
112 def create_pyoxidizer_install_layout( |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
113 source_dir: pathlib.Path, |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
114 build_dir: pathlib.Path, |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
115 out_dir: pathlib.Path, |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
116 target_triple: str, |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
117 ): |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
118 """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
|
119 |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
120 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
|
121 Mercurial install. |
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 |
d09b36f69180
packaging: extract invocation of pyoxidizer to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
47208
diff
changeset
|
124 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
|
125 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
126 if "windows" in target_triple: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
127 target = "app_windows" |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
128 else: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
129 target = "app_posix" |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
130 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
131 build_dir = ( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
132 source_dir / "build" / "pyoxidizer" / target_triple / "release" / target |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
133 ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
134 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
135 if out_dir.exists(): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
136 print("purging %s" % out_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
137 shutil.rmtree(out_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
138 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
139 # 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
|
140 shutil.copytree(build_dir, out_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
141 |
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
142 # 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
|
143 # 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
|
144 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
|
145 |
47207
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
146 build_docs_html(source_dir) |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
147 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
148 if "windows" in target_triple: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
149 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
|
150 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
151 # 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
|
152 # 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
|
153 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
|
154 with (out_dir / "defaultrc" / "editor.rc").open( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
155 "w", encoding="utf-8" |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
156 ) as fh: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
157 fh.write("[ui]\neditor = notepad\n") |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
158 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
159 for f in STAGING_EXCLUDES_WINDOWS: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
160 p = out_dir / f |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
161 if p.exists(): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
162 print("removing %s" % p) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
163 p.unlink() |
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 # Add vcruntimeXXX.dll next to executable. |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
166 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
|
167 shutil.copy(vc_runtime_dll, out_dir / vc_runtime_dll.name) |