Mercurial > hg
annotate contrib/packaging/hgpackaging/pyoxidizer.py @ 47207:41be7698a4fd
packaging: move documentation HTML building to own function
This is part of some light refactoring to enable us to use
PyOxidizer for WiX MSI installer generation.
Differential Revision: https://phab.mercurial-scm.org/D10685
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 06 May 2021 08:37:40 -0700 |
parents | 37bcd7f5a543 |
children | df1767fa822d |
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 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
71 def run_pyoxidizer( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
72 source_dir: pathlib.Path, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
73 build_dir: pathlib.Path, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
74 out_dir: pathlib.Path, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
75 target_triple: str, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
76 ): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
77 """Build Mercurial with PyOxidizer and copy additional files into place. |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
78 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
79 After successful completion, ``out_dir`` contains files constituting a |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
80 Mercurial install. |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
81 """ |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
82 # 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
|
83 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
|
84 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
|
85 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
86 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
|
87 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
88 if not gettext_root.exists(): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
89 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
|
90 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
|
91 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
92 env = dict(os.environ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
93 env["PATH"] = "%s%s%s" % ( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
94 env["PATH"], |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
95 os.pathsep, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 str(gettext_root / "bin"), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
99 args = [ |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 "pyoxidizer", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 "build", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
102 "--path", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 str(source_dir / "rust" / "hgcli"), |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
104 "--release", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
105 "--target-triple", |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
106 target_triple, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
107 ] |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
108 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
109 subprocess.run(args, env=env, check=True) |
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 if "windows" in target_triple: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
112 target = "app_windows" |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
113 else: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
114 target = "app_posix" |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
115 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
116 build_dir = ( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
117 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
|
118 ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
119 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
120 if out_dir.exists(): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
121 print("purging %s" % out_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
122 shutil.rmtree(out_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
123 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
124 # 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
|
125 shutil.copytree(build_dir, out_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
126 |
45685
57b5452a55d5
pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
127 # 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
|
128 # 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
|
129 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
|
130 |
47207
41be7698a4fd
packaging: move documentation HTML building to own function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45922
diff
changeset
|
131 build_docs_html(source_dir) |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
132 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
133 if "windows" in target_triple: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
134 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
|
135 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
136 # 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
|
137 # 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
|
138 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
|
139 with (out_dir / "defaultrc" / "editor.rc").open( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
140 "w", encoding="utf-8" |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
141 ) as fh: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
142 fh.write("[ui]\neditor = notepad\n") |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
143 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
144 for f in STAGING_EXCLUDES_WINDOWS: |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
145 p = out_dir / f |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
146 if p.exists(): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
147 print("removing %s" % p) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
148 p.unlink() |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
149 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
150 # Add vcruntimeXXX.dll next to executable. |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
151 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
|
152 shutil.copy(vc_runtime_dll, out_dir / vc_runtime_dll.name) |