Show More
@@ -1,93 +1,112 b'' | |||||
1 | # inno.py - Inno Setup functionality. |
|
1 | # inno.py - Inno Setup functionality. | |
2 | # |
|
2 | # | |
3 | # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> |
|
3 | # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | # no-check-code because Python 3 native. |
|
8 | # no-check-code because Python 3 native. | |
9 |
|
9 | |||
10 | import os |
|
10 | import os | |
11 | import pathlib |
|
11 | import pathlib | |
12 | import shutil |
|
12 | import shutil | |
13 | import subprocess |
|
13 | import subprocess | |
14 |
|
14 | |||
|
15 | import jinja2 | |||
|
16 | ||||
15 | from .py2exe import build_py2exe |
|
17 | from .py2exe import build_py2exe | |
16 | from .util import find_vc_runtime_files |
|
18 | from .util import find_vc_runtime_files | |
17 |
|
19 | |||
18 | EXTRA_PACKAGES = { |
|
20 | EXTRA_PACKAGES = { | |
19 | 'dulwich', |
|
21 | 'dulwich', | |
20 | 'keyring', |
|
22 | 'keyring', | |
21 | 'pygments', |
|
23 | 'pygments', | |
22 | 'win32ctypes', |
|
24 | 'win32ctypes', | |
23 | } |
|
25 | } | |
24 |
|
26 | |||
25 |
|
27 | |||
26 | def build( |
|
28 | def build( | |
27 | source_dir: pathlib.Path, |
|
29 | source_dir: pathlib.Path, | |
28 | build_dir: pathlib.Path, |
|
30 | build_dir: pathlib.Path, | |
29 | python_exe: pathlib.Path, |
|
31 | python_exe: pathlib.Path, | |
30 | iscc_exe: pathlib.Path, |
|
32 | iscc_exe: pathlib.Path, | |
31 | version=None, |
|
33 | version=None, | |
32 | ): |
|
34 | ): | |
33 | """Build the Inno installer. |
|
35 | """Build the Inno installer. | |
34 |
|
36 | |||
35 | Build files will be placed in ``build_dir``. |
|
37 | Build files will be placed in ``build_dir``. | |
36 |
|
38 | |||
37 | py2exe's setup.py doesn't use setuptools. It doesn't have modern logic |
|
39 | py2exe's setup.py doesn't use setuptools. It doesn't have modern logic | |
38 | for finding the Python 2.7 toolchain. So, we require the environment |
|
40 | for finding the Python 2.7 toolchain. So, we require the environment | |
39 | to already be configured with an active toolchain. |
|
41 | to already be configured with an active toolchain. | |
40 | """ |
|
42 | """ | |
41 | if not iscc_exe.exists(): |
|
43 | if not iscc_exe.exists(): | |
42 | raise Exception('%s does not exist' % iscc_exe) |
|
44 | raise Exception('%s does not exist' % iscc_exe) | |
43 |
|
45 | |||
44 | vc_x64 = r'\x64' in os.environ.get('LIB', '') |
|
46 | vc_x64 = r'\x64' in os.environ.get('LIB', '') | |
45 | arch = 'x64' if vc_x64 else 'x86' |
|
47 | arch = 'x64' if vc_x64 else 'x86' | |
46 | inno_source_dir = source_dir / 'contrib' / 'packaging' / 'inno' |
|
48 | inno_source_dir = source_dir / 'contrib' / 'packaging' / 'inno' | |
47 | inno_build_dir = build_dir / ('inno-%s' % arch) |
|
49 | inno_build_dir = build_dir / ('inno-%s' % arch) | |
48 |
|
50 | |||
49 | requirements_txt = ( |
|
51 | requirements_txt = ( | |
50 | source_dir / 'contrib' / 'packaging' / 'inno' / 'requirements.txt' |
|
52 | source_dir / 'contrib' / 'packaging' / 'inno' / 'requirements.txt' | |
51 | ) |
|
53 | ) | |
52 |
|
54 | |||
53 | inno_build_dir.mkdir(parents=True, exist_ok=True) |
|
55 | inno_build_dir.mkdir(parents=True, exist_ok=True) | |
54 |
|
56 | |||
55 | build_py2exe( |
|
57 | build_py2exe( | |
56 | source_dir, |
|
58 | source_dir, | |
57 | build_dir, |
|
59 | build_dir, | |
58 | python_exe, |
|
60 | python_exe, | |
59 | 'inno', |
|
61 | 'inno', | |
60 | requirements_txt, |
|
62 | requirements_txt, | |
61 | extra_packages=EXTRA_PACKAGES, |
|
63 | extra_packages=EXTRA_PACKAGES, | |
62 | ) |
|
64 | ) | |
63 |
|
65 | |||
64 | # hg.exe depends on VC9 runtime DLLs. Copy those into place. |
|
66 | # hg.exe depends on VC9 runtime DLLs. Copy those into place. | |
65 | for f in find_vc_runtime_files(vc_x64): |
|
67 | for f in find_vc_runtime_files(vc_x64): | |
66 | if f.name.endswith('.manifest'): |
|
68 | if f.name.endswith('.manifest'): | |
67 | basename = 'Microsoft.VC90.CRT.manifest' |
|
69 | basename = 'Microsoft.VC90.CRT.manifest' | |
68 | else: |
|
70 | else: | |
69 | basename = f.name |
|
71 | basename = f.name | |
70 |
|
72 | |||
71 | dest_path = source_dir / 'dist' / basename |
|
73 | dest_path = source_dir / 'dist' / basename | |
72 |
|
74 | |||
73 | print('copying %s to %s' % (f, dest_path)) |
|
75 | print('copying %s to %s' % (f, dest_path)) | |
74 | shutil.copyfile(f, dest_path) |
|
76 | shutil.copyfile(f, dest_path) | |
75 |
|
77 | |||
76 | print('creating installer') |
|
78 | print('creating installer') | |
77 |
|
79 | |||
78 |
# |
|
80 | # Install Inno files by rendering a template. | |
79 | for p in ('mercurial.iss', 'modpath.iss'): |
|
81 | jinja_env = jinja2.Environment( | |
80 | shutil.copyfile(inno_source_dir / p, inno_build_dir / p) |
|
82 | loader=jinja2.FileSystemLoader(str(inno_source_dir)), | |
|
83 | # Need to change these to prevent conflict with Inno Setup. | |||
|
84 | comment_start_string='{##', | |||
|
85 | comment_end_string='##}', | |||
|
86 | ) | |||
|
87 | ||||
|
88 | try: | |||
|
89 | template = jinja_env.get_template('mercurial.iss') | |||
|
90 | except jinja2.TemplateSyntaxError as e: | |||
|
91 | raise Exception( | |||
|
92 | 'template syntax error at %s:%d: %s' | |||
|
93 | % (e.name, e.lineno, e.message,) | |||
|
94 | ) | |||
|
95 | ||||
|
96 | content = template.render() | |||
|
97 | ||||
|
98 | with (inno_build_dir / 'mercurial.iss').open('w', encoding='utf-8') as fh: | |||
|
99 | fh.write(content) | |||
81 |
|
100 | |||
82 | args = [str(iscc_exe)] |
|
101 | args = [str(iscc_exe)] | |
83 |
|
102 | |||
84 | if vc_x64: |
|
103 | if vc_x64: | |
85 | args.append('/dARCH=x64') |
|
104 | args.append('/dARCH=x64') | |
86 |
|
105 | |||
87 | if version: |
|
106 | if version: | |
88 | args.append('/dVERSION=%s' % version) |
|
107 | args.append('/dVERSION=%s' % version) | |
89 |
|
108 | |||
90 | args.append('/Odist') |
|
109 | args.append('/Odist') | |
91 | args.append(str(inno_build_dir / 'mercurial.iss')) |
|
110 | args.append(str(inno_build_dir / 'mercurial.iss')) | |
92 |
|
111 | |||
93 | subprocess.run(args, cwd=str(source_dir), check=True) |
|
112 | subprocess.run(args, cwd=str(source_dir), check=True) |
@@ -1,124 +1,125 b'' | |||||
1 | ; Script generated by the Inno Setup Script Wizard. |
|
1 | ; Script generated by the Inno Setup Script Wizard. | |
2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! |
|
2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! | |
3 |
|
3 | |||
4 | #ifndef VERSION |
|
4 | #ifndef VERSION | |
5 | #define FileHandle |
|
5 | #define FileHandle | |
6 | #define FileLine |
|
6 | #define FileLine | |
7 | #define VERSION = "unknown" |
|
7 | #define VERSION = "unknown" | |
8 | #if FileHandle = FileOpen(SourcePath + "\..\..\mercurial\__version__.py") |
|
8 | #if FileHandle = FileOpen(SourcePath + "\..\..\mercurial\__version__.py") | |
9 | #expr FileLine = FileRead(FileHandle) |
|
9 | #expr FileLine = FileRead(FileHandle) | |
10 | #expr FileLine = FileRead(FileHandle) |
|
10 | #expr FileLine = FileRead(FileHandle) | |
11 | #define VERSION = Copy(FileLine, Pos('"', FileLine)+1, Len(FileLine)-Pos('"', FileLine)-1) |
|
11 | #define VERSION = Copy(FileLine, Pos('"', FileLine)+1, Len(FileLine)-Pos('"', FileLine)-1) | |
12 | #endif |
|
12 | #endif | |
13 | #if FileHandle |
|
13 | #if FileHandle | |
14 | #expr FileClose(FileHandle) |
|
14 | #expr FileClose(FileHandle) | |
15 | #endif |
|
15 | #endif | |
16 | #pragma message "Detected Version: " + VERSION |
|
16 | #pragma message "Detected Version: " + VERSION | |
17 | #endif |
|
17 | #endif | |
18 |
|
18 | |||
19 | #ifndef ARCH |
|
19 | #ifndef ARCH | |
20 | #define ARCH = "x86" |
|
20 | #define ARCH = "x86" | |
21 | #endif |
|
21 | #endif | |
22 |
|
22 | |||
23 | [Setup] |
|
23 | [Setup] | |
24 | AppCopyright=Copyright 2005-2019 Matt Mackall and others |
|
24 | AppCopyright=Copyright 2005-2019 Matt Mackall and others | |
25 | AppName=Mercurial |
|
25 | AppName=Mercurial | |
26 | AppVersion={#VERSION} |
|
26 | AppVersion={#VERSION} | |
27 | #if ARCH == "x64" |
|
27 | #if ARCH == "x64" | |
28 | AppVerName=Mercurial {#VERSION} (64-bit) |
|
28 | AppVerName=Mercurial {#VERSION} (64-bit) | |
29 | OutputBaseFilename=Mercurial-{#VERSION}-x64 |
|
29 | OutputBaseFilename=Mercurial-{#VERSION}-x64 | |
30 | ArchitecturesAllowed=x64 |
|
30 | ArchitecturesAllowed=x64 | |
31 | ArchitecturesInstallIn64BitMode=x64 |
|
31 | ArchitecturesInstallIn64BitMode=x64 | |
32 | #else |
|
32 | #else | |
33 | AppVerName=Mercurial {#VERSION} |
|
33 | AppVerName=Mercurial {#VERSION} | |
34 | OutputBaseFilename=Mercurial-{#VERSION} |
|
34 | OutputBaseFilename=Mercurial-{#VERSION} | |
35 | #endif |
|
35 | #endif | |
36 | InfoAfterFile=contrib/win32/postinstall.txt |
|
36 | InfoAfterFile=contrib/win32/postinstall.txt | |
37 | LicenseFile=COPYING |
|
37 | LicenseFile=COPYING | |
38 | ShowLanguageDialog=yes |
|
38 | ShowLanguageDialog=yes | |
39 | AppPublisher=Matt Mackall and others |
|
39 | AppPublisher=Matt Mackall and others | |
40 | AppPublisherURL=https://mercurial-scm.org/ |
|
40 | AppPublisherURL=https://mercurial-scm.org/ | |
41 | AppSupportURL=https://mercurial-scm.org/ |
|
41 | AppSupportURL=https://mercurial-scm.org/ | |
42 | AppUpdatesURL=https://mercurial-scm.org/ |
|
42 | AppUpdatesURL=https://mercurial-scm.org/ | |
43 | AppID={{4B95A5F1-EF59-4B08-BED8-C891C46121B3} |
|
43 | {{ 'AppID={{4B95A5F1-EF59-4B08-BED8-C891C46121B3}' }} | |
44 | AppContact=mercurial@mercurial-scm.org |
|
44 | AppContact=mercurial@mercurial-scm.org | |
45 | DefaultDirName={pf}\Mercurial |
|
45 | DefaultDirName={pf}\Mercurial | |
46 | SourceDir=..\.. |
|
46 | SourceDir=..\.. | |
47 | VersionInfoDescription=Mercurial distributed SCM (version {#VERSION}) |
|
47 | VersionInfoDescription=Mercurial distributed SCM (version {#VERSION}) | |
48 | VersionInfoCopyright=Copyright 2005-2019 Matt Mackall and others |
|
48 | VersionInfoCopyright=Copyright 2005-2019 Matt Mackall and others | |
49 | VersionInfoCompany=Matt Mackall and others |
|
49 | VersionInfoCompany=Matt Mackall and others | |
50 | InternalCompressLevel=max |
|
50 | InternalCompressLevel=max | |
51 | SolidCompression=true |
|
51 | SolidCompression=true | |
52 | SetupIconFile=contrib\win32\mercurial.ico |
|
52 | SetupIconFile=contrib\win32\mercurial.ico | |
53 | AllowNoIcons=true |
|
53 | AllowNoIcons=true | |
54 | DefaultGroupName=Mercurial |
|
54 | DefaultGroupName=Mercurial | |
55 | PrivilegesRequired=none |
|
55 | PrivilegesRequired=none | |
56 | ChangesEnvironment=true |
|
56 | ChangesEnvironment=true | |
57 |
|
57 | |||
58 | [Files] |
|
58 | [Files] | |
59 | Source: contrib\mercurial.el; DestDir: {app}/Contrib |
|
59 | Source: contrib\mercurial.el; DestDir: {app}/Contrib | |
60 | Source: contrib\vim\*.*; DestDir: {app}/Contrib/Vim |
|
60 | Source: contrib\vim\*.*; DestDir: {app}/Contrib/Vim | |
61 | Source: contrib\zsh_completion; DestDir: {app}/Contrib |
|
61 | Source: contrib\zsh_completion; DestDir: {app}/Contrib | |
62 | Source: contrib\bash_completion; DestDir: {app}/Contrib |
|
62 | Source: contrib\bash_completion; DestDir: {app}/Contrib | |
63 | Source: contrib\tcsh_completion; DestDir: {app}/Contrib |
|
63 | Source: contrib\tcsh_completion; DestDir: {app}/Contrib | |
64 | Source: contrib\tcsh_completion_build.sh; DestDir: {app}/Contrib |
|
64 | Source: contrib\tcsh_completion_build.sh; DestDir: {app}/Contrib | |
65 | Source: contrib\hgk; DestDir: {app}/Contrib; DestName: hgk.tcl |
|
65 | Source: contrib\hgk; DestDir: {app}/Contrib; DestName: hgk.tcl | |
66 | Source: contrib\xml.rnc; DestDir: {app}/Contrib |
|
66 | Source: contrib\xml.rnc; DestDir: {app}/Contrib | |
67 | Source: contrib\mercurial.el; DestDir: {app}/Contrib |
|
67 | Source: contrib\mercurial.el; DestDir: {app}/Contrib | |
68 | Source: contrib\mq.el; DestDir: {app}/Contrib |
|
68 | Source: contrib\mq.el; DestDir: {app}/Contrib | |
69 | Source: contrib\hgweb.fcgi; DestDir: {app}/Contrib |
|
69 | Source: contrib\hgweb.fcgi; DestDir: {app}/Contrib | |
70 | Source: contrib\hgweb.wsgi; DestDir: {app}/Contrib |
|
70 | Source: contrib\hgweb.wsgi; DestDir: {app}/Contrib | |
71 | Source: contrib\win32\ReadMe.html; DestDir: {app}; Flags: isreadme |
|
71 | Source: contrib\win32\ReadMe.html; DestDir: {app}; Flags: isreadme | |
72 | Source: contrib\win32\postinstall.txt; DestDir: {app}; DestName: ReleaseNotes.txt |
|
72 | Source: contrib\win32\postinstall.txt; DestDir: {app}; DestName: ReleaseNotes.txt | |
73 | Source: dist\hg.exe; DestDir: {app}; AfterInstall: Touch('{app}\hg.exe.local') |
|
73 | Source: dist\hg.exe; DestDir: {app}; AfterInstall: Touch('{app}\hg.exe.local') | |
74 | Source: dist\lib\*.dll; Destdir: {app}\lib |
|
74 | Source: dist\lib\*.dll; Destdir: {app}\lib | |
75 | Source: dist\lib\*.pyd; Destdir: {app}\lib |
|
75 | Source: dist\lib\*.pyd; Destdir: {app}\lib | |
76 | Source: dist\python*.dll; Destdir: {app}; Flags: skipifsourcedoesntexist |
|
76 | Source: dist\python*.dll; Destdir: {app}; Flags: skipifsourcedoesntexist | |
77 | Source: dist\msvc*.dll; DestDir: {app}; Flags: skipifsourcedoesntexist |
|
77 | Source: dist\msvc*.dll; DestDir: {app}; Flags: skipifsourcedoesntexist | |
78 | Source: dist\Microsoft.VC*.CRT.manifest; DestDir: {app}; Flags: skipifsourcedoesntexist |
|
78 | Source: dist\Microsoft.VC*.CRT.manifest; DestDir: {app}; Flags: skipifsourcedoesntexist | |
79 | Source: dist\lib\library.zip; DestDir: {app}\lib |
|
79 | Source: dist\lib\library.zip; DestDir: {app}\lib | |
80 | Source: doc\*.html; DestDir: {app}\Docs |
|
80 | Source: doc\*.html; DestDir: {app}\Docs | |
81 | Source: doc\style.css; DestDir: {app}\Docs |
|
81 | Source: doc\style.css; DestDir: {app}\Docs | |
82 | Source: mercurial\help\*.txt; DestDir: {app}\help |
|
82 | Source: mercurial\help\*.txt; DestDir: {app}\help | |
83 | Source: mercurial\help\internals\*.txt; DestDir: {app}\help\internals |
|
83 | Source: mercurial\help\internals\*.txt; DestDir: {app}\help\internals | |
84 | Source: mercurial\default.d\*.rc; DestDir: {app}\default.d |
|
84 | Source: mercurial\default.d\*.rc; DestDir: {app}\default.d | |
85 | Source: mercurial\locale\*.*; DestDir: {app}\locale; Flags: recursesubdirs createallsubdirs skipifsourcedoesntexist |
|
85 | Source: mercurial\locale\*.*; DestDir: {app}\locale; Flags: recursesubdirs createallsubdirs skipifsourcedoesntexist | |
86 | Source: mercurial\templates\*.*; DestDir: {app}\Templates; Flags: recursesubdirs createallsubdirs |
|
86 | Source: mercurial\templates\*.*; DestDir: {app}\Templates; Flags: recursesubdirs createallsubdirs | |
87 | Source: CONTRIBUTORS; DestDir: {app}; DestName: Contributors.txt |
|
87 | Source: CONTRIBUTORS; DestDir: {app}; DestName: Contributors.txt | |
88 | Source: COPYING; DestDir: {app}; DestName: Copying.txt |
|
88 | Source: COPYING; DestDir: {app}; DestName: Copying.txt | |
89 |
|
89 | |||
90 | [INI] |
|
90 | [INI] | |
91 | Filename: {app}\Mercurial.url; Section: InternetShortcut; Key: URL; String: https://mercurial-scm.org/ |
|
91 | Filename: {app}\Mercurial.url; Section: InternetShortcut; Key: URL; String: https://mercurial-scm.org/ | |
92 | Filename: {app}\default.d\editor.rc; Section: ui; Key: editor; String: notepad |
|
92 | Filename: {app}\default.d\editor.rc; Section: ui; Key: editor; String: notepad | |
93 |
|
93 | |||
94 | [UninstallDelete] |
|
94 | [UninstallDelete] | |
95 | Type: files; Name: {app}\Mercurial.url |
|
95 | Type: files; Name: {app}\Mercurial.url | |
96 | Type: filesandordirs; Name: {app}\default.d |
|
96 | Type: filesandordirs; Name: {app}\default.d | |
97 | Type: files; Name: "{app}\hg.exe.local" |
|
97 | Type: files; Name: "{app}\hg.exe.local" | |
98 |
|
98 | |||
99 | [Icons] |
|
99 | [Icons] | |
100 | Name: {group}\Uninstall Mercurial; Filename: {uninstallexe} |
|
100 | Name: {group}\Uninstall Mercurial; Filename: {uninstallexe} | |
101 | Name: {group}\Mercurial Command Reference; Filename: {app}\Docs\hg.1.html |
|
101 | Name: {group}\Mercurial Command Reference; Filename: {app}\Docs\hg.1.html | |
102 | Name: {group}\Mercurial Configuration Files; Filename: {app}\Docs\hgrc.5.html |
|
102 | Name: {group}\Mercurial Configuration Files; Filename: {app}\Docs\hgrc.5.html | |
103 | Name: {group}\Mercurial Ignore Files; Filename: {app}\Docs\hgignore.5.html |
|
103 | Name: {group}\Mercurial Ignore Files; Filename: {app}\Docs\hgignore.5.html | |
104 | Name: {group}\Mercurial Web Site; Filename: {app}\Mercurial.url |
|
104 | Name: {group}\Mercurial Web Site; Filename: {app}\Mercurial.url | |
105 |
|
105 | |||
106 | [Tasks] |
|
106 | [Tasks] | |
107 | Name: modifypath; Description: Add the installation path to the search path; Flags: unchecked |
|
107 | Name: modifypath; Description: Add the installation path to the search path; Flags: unchecked | |
108 |
|
108 | |||
109 | [Code] |
|
109 | [Code] | |
110 | procedure Touch(fn: String); |
|
110 | procedure Touch(fn: String); | |
111 | begin |
|
111 | begin | |
112 | SaveStringToFile(ExpandConstant(fn), '', False); |
|
112 | SaveStringToFile(ExpandConstant(fn), '', False); | |
113 | end; |
|
113 | end; | |
114 |
|
114 | |||
115 | const |
|
115 | const | |
116 | ModPathName = 'modifypath'; |
|
116 | ModPathName = 'modifypath'; | |
117 | ModPathType = 'user'; |
|
117 | ModPathType = 'user'; | |
118 |
|
118 | |||
119 | function ModPathDir(): TArrayOfString; |
|
119 | function ModPathDir(): TArrayOfString; | |
120 | begin |
|
120 | begin | |
121 | setArrayLength(Result, 1) |
|
121 | setArrayLength(Result, 1) | |
122 | Result[0] := ExpandConstant('{app}'); |
|
122 | Result[0] := ExpandConstant('{app}'); | |
123 | end; |
|
123 | end; | |
124 | #include "modpath.iss" |
|
124 | ||
|
125 | {% include 'modpath.iss' %} |
General Comments 0
You need to be logged in to leave comments.
Login now