Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/command/bdist_wininst.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 40eff3b182e4 |
| children | 3e2b7965ada9 |
| rev | line source |
|---|---|
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1 """distutils.command.bdist_wininst |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
2 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
3 Implements the Distutils 'bdist_wininst' command: create a windows installer |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
4 exe-program.""" |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
5 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
6 __revision__ = "$Id$" |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
7 |
|
13042
1f2441978ab1
Fixed to use 'reinitialize_command()' to fetch "install" and "install_lib"
Greg Ward <gward@python.net>
parents:
13031
diff
changeset
|
8 import sys, os, string |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
9 from distutils.core import Command |
|
13871
8307446bc6aa
Fixed imports from '*util' modules to not just import everything from util.
Greg Ward <gward@python.net>
parents:
13350
diff
changeset
|
10 from distutils.util import get_platform |
|
8307446bc6aa
Fixed imports from '*util' modules to not just import everything from util.
Greg Ward <gward@python.net>
parents:
13350
diff
changeset
|
11 from distutils.dir_util import create_tree, remove_tree |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
12 from distutils.errors import * |
|
26358
79118632e37e
get_python_version was not imported.
Thomas Heller <theller@ctypes.org>
parents:
26285
diff
changeset
|
13 from distutils.sysconfig import get_python_version |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22911
diff
changeset
|
14 from distutils import log |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
15 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
16 class bdist_wininst (Command): |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
17 |
|
13042
1f2441978ab1
Fixed to use 'reinitialize_command()' to fetch "install" and "install_lib"
Greg Ward <gward@python.net>
parents:
13031
diff
changeset
|
18 description = "create an executable installer for MS Windows" |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
19 |
|
17060
3f5276cbbc4d
The bdist_wininst.py command has been recreated after wininst.exe
Thomas Heller <theller@ctypes.org>
parents:
16675
diff
changeset
|
20 user_options = [('bdist-dir=', None, |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
21 "temporary directory for creating the distribution"), |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
22 ('plat-name=', 'p', |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
23 "platform name to embed in generated filenames " |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
24 "(default: %s)" % get_platform()), |
|
14633
7d0e3450ee41
Renamed --keep-tree to --keep-temp.
Greg Ward <gward@python.net>
parents:
14496
diff
changeset
|
25 ('keep-temp', 'k', |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
26 "keep the pseudo-installation tree around after " + |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
27 "creating the distribution archive"), |
| 32511 | 28 ('target-version=', None, |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
29 "require a specific python version" + |
|
14218
e79d3cf4443e
New release of the Windows installer from Thomas Heller.
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
30 " on the target system"), |
| 14454 | 31 ('no-target-compile', 'c', |
| 32 "do not compile .py to .pyc on the target system"), | |
| 33 ('no-target-optimize', 'o', | |
|
14923
75f3d5e7b89c
Removed the extra_dirs and path_file metadata options.
Thomas Heller <theller@ctypes.org>
parents:
14829
diff
changeset
|
34 "do not compile .py to .pyo (optimized)" |
|
75f3d5e7b89c
Removed the extra_dirs and path_file metadata options.
Thomas Heller <theller@ctypes.org>
parents:
14829
diff
changeset
|
35 "on the target system"), |
|
13350
e0d676e9cb66
Fixed so the ZIP file (which is bundled into an executable) goes in the
Greg Ward <gward@python.net>
parents:
13165
diff
changeset
|
36 ('dist-dir=', 'd', |
|
e0d676e9cb66
Fixed so the ZIP file (which is bundled into an executable) goes in the
Greg Ward <gward@python.net>
parents:
13165
diff
changeset
|
37 "directory to put final built distributions in"), |
|
16675
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
38 ('bitmap=', 'b', |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
39 "bitmap to use for the installer instead of python-powered logo"), |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
40 ('title=', 't', |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
41 "title to display on the installer background instead of default"), |
|
21714
630293be1035
Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents:
21472
diff
changeset
|
42 ('skip-build', None, |
|
630293be1035
Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents:
21472
diff
changeset
|
43 "skip rebuilding everything (for testing/debugging)"), |
|
21987
0f63111bf4c5
First version which runs an install-script (specified by the
Thomas Heller <theller@ctypes.org>
parents:
21714
diff
changeset
|
44 ('install-script=', None, |
|
26034
183fc21fb866
Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents:
25805
diff
changeset
|
45 "basename of installation script to be run after" |
|
183fc21fb866
Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents:
25805
diff
changeset
|
46 "installation or before deinstallation"), |
|
31565
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
47 ('pre-install-script=', None, |
|
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
48 "Fully qualified filename of a script to be run before " |
|
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
49 "any files are installed. This script need not be in the " |
|
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
50 "distribution"), |
|
46624
0ba12c32e2b5
#2581: Vista UAC/elevation support for bdist_wininst
Mark Hammond <mhammond@skippinet.com.au>
parents:
46331
diff
changeset
|
51 ('user-access-control=', None, |
|
0ba12c32e2b5
#2581: Vista UAC/elevation support for bdist_wininst
Mark Hammond <mhammond@skippinet.com.au>
parents:
46331
diff
changeset
|
52 "specify Vista's UAC handling - 'none'/default=no " |
|
0ba12c32e2b5
#2581: Vista UAC/elevation support for bdist_wininst
Mark Hammond <mhammond@skippinet.com.au>
parents:
46331
diff
changeset
|
53 "handling, 'auto'=use UAC if target Python installed for " |
|
0ba12c32e2b5
#2581: Vista UAC/elevation support for bdist_wininst
Mark Hammond <mhammond@skippinet.com.au>
parents:
46331
diff
changeset
|
54 "all users, 'force'=always use UAC"), |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
55 ] |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
56 |
|
22434
c0ae6f46f231
Add unlisted Boolean options. Thomas H., can you please check that I
Andrew M. Kuchling <amk@amk.ca>
parents:
21987
diff
changeset
|
57 boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize', |
|
c0ae6f46f231
Add unlisted Boolean options. Thomas H., can you please check that I
Andrew M. Kuchling <amk@amk.ca>
parents:
21987
diff
changeset
|
58 'skip-build'] |
|
14829
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14745
diff
changeset
|
59 |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
60 def initialize_options (self): |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
61 self.bdist_dir = None |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
62 self.plat_name = None |
|
14633
7d0e3450ee41
Renamed --keep-tree to --keep-temp.
Greg Ward <gward@python.net>
parents:
14496
diff
changeset
|
63 self.keep_temp = 0 |
| 14454 | 64 self.no_target_compile = 0 |
| 65 self.no_target_optimize = 0 | |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
66 self.target_version = None |
|
13350
e0d676e9cb66
Fixed so the ZIP file (which is bundled into an executable) goes in the
Greg Ward <gward@python.net>
parents:
13165
diff
changeset
|
67 self.dist_dir = None |
|
16675
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
68 self.bitmap = None |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
69 self.title = None |
|
21714
630293be1035
Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents:
21472
diff
changeset
|
70 self.skip_build = 0 |
|
21987
0f63111bf4c5
First version which runs an install-script (specified by the
Thomas Heller <theller@ctypes.org>
parents:
21714
diff
changeset
|
71 self.install_script = None |
|
31565
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
72 self.pre_install_script = None |
|
46624
0ba12c32e2b5
#2581: Vista UAC/elevation support for bdist_wininst
Mark Hammond <mhammond@skippinet.com.au>
parents:
46331
diff
changeset
|
73 self.user_access_control = None |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
74 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
75 # initialize_options() |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
76 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
77 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
78 def finalize_options (self): |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
79 if self.bdist_dir is None: |
|
47356
67f4b7767a0a
bdist_wininst now works correctly when both --skip-build and --plat-name are specified.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46624
diff
changeset
|
80 if self.skip_build and self.plat_name: |
|
67f4b7767a0a
bdist_wininst now works correctly when both --skip-build and --plat-name are specified.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46624
diff
changeset
|
81 # If build is skipped and plat_name is overridden, bdist will |
|
67f4b7767a0a
bdist_wininst now works correctly when both --skip-build and --plat-name are specified.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46624
diff
changeset
|
82 # not see the correct 'plat_name' - so set that up manually. |
|
67f4b7767a0a
bdist_wininst now works correctly when both --skip-build and --plat-name are specified.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46624
diff
changeset
|
83 bdist = self.distribution.get_command_obj('bdist') |
|
67f4b7767a0a
bdist_wininst now works correctly when both --skip-build and --plat-name are specified.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46624
diff
changeset
|
84 bdist.plat_name = self.plat_name |
|
67f4b7767a0a
bdist_wininst now works correctly when both --skip-build and --plat-name are specified.
Mark Hammond <mhammond@skippinet.com.au>
parents:
46624
diff
changeset
|
85 # next the command will be initialized using that name |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
86 bdist_base = self.get_finalized_command('bdist').bdist_base |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
87 self.bdist_dir = os.path.join(bdist_base, 'wininst') |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
88 if not self.target_version: |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
89 self.target_version = "" |
|
31565
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
90 if not self.skip_build and self.distribution.has_ext_modules(): |
|
26206
ff92cc27fd1f
[Bug #550364] Use sysconfig.get_python_version()
Andrew M. Kuchling <amk@amk.ca>
parents:
26096
diff
changeset
|
91 short_version = get_python_version() |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
92 if self.target_version and self.target_version != short_version: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
93 raise DistutilsOptionError, \ |
|
31565
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
94 "target version can only be %s, or the '--skip_build'" \ |
|
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
95 " option must be specified" % (short_version,) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
96 self.target_version = short_version |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
97 |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
98 self.set_undefined_options('bdist', |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
99 ('dist_dir', 'dist_dir'), |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
100 ('plat_name', 'plat_name'), |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
101 ) |
|
13350
e0d676e9cb66
Fixed so the ZIP file (which is bundled into an executable) goes in the
Greg Ward <gward@python.net>
parents:
13165
diff
changeset
|
102 |
|
26034
183fc21fb866
Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents:
25805
diff
changeset
|
103 if self.install_script: |
|
183fc21fb866
Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents:
25805
diff
changeset
|
104 for script in self.distribution.scripts: |
|
183fc21fb866
Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents:
25805
diff
changeset
|
105 if self.install_script == os.path.basename(script): |
|
183fc21fb866
Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents:
25805
diff
changeset
|
106 break |
|
183fc21fb866
Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents:
25805
diff
changeset
|
107 else: |
|
183fc21fb866
Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents:
25805
diff
changeset
|
108 raise DistutilsOptionError, \ |
|
183fc21fb866
Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents:
25805
diff
changeset
|
109 "install_script '%s' not found in scripts" % \ |
|
183fc21fb866
Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents:
25805
diff
changeset
|
110 self.install_script |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
111 # finalize_options() |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
112 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
113 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
114 def run (self): |
|
14324
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
115 if (sys.platform != "win32" and |
|
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
116 (self.distribution.has_ext_modules() or |
|
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
117 self.distribution.has_c_libraries())): |
| 14454 | 118 raise DistutilsPlatformError \ |
|
14324
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
119 ("distribution contains extensions and/or C libraries; " |
|
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
120 "must be compiled on a Windows 32 platform") |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
121 |
|
21714
630293be1035
Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents:
21472
diff
changeset
|
122 if not self.skip_build: |
|
630293be1035
Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents:
21472
diff
changeset
|
123 self.run_command('build') |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
124 |
|
29427
edcfef944e2f
Fix for sf # 749210, wininst isn't build correctly after building zip.
Thomas Heller <theller@ctypes.org>
parents:
26359
diff
changeset
|
125 install = self.reinitialize_command('install', reinit_subcommands=1) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
126 install.root = self.bdist_dir |
|
21714
630293be1035
Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents:
21472
diff
changeset
|
127 install.skip_build = self.skip_build |
|
22911
0773d23224d2
Set the warn_dir option to 0 before running the install command.
Thomas Heller <theller@ctypes.org>
parents:
22434
diff
changeset
|
128 install.warn_dir = 0 |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
129 install.plat_name = self.plat_name |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
130 |
|
13042
1f2441978ab1
Fixed to use 'reinitialize_command()' to fetch "install" and "install_lib"
Greg Ward <gward@python.net>
parents:
13031
diff
changeset
|
131 install_lib = self.reinitialize_command('install_lib') |
|
14218
e79d3cf4443e
New release of the Windows installer from Thomas Heller.
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
132 # we do not want to include pyc or pyo files |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
133 install_lib.compile = 0 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
134 install_lib.optimize = 0 |
|
32736
c3a096bfbd6b
Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents:
32511
diff
changeset
|
135 |
|
33852
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
136 if self.distribution.has_ext_modules(): |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
137 # If we are building an installer for a Python version other |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
138 # than the one we are currently running, then we need to ensure |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
139 # our build_lib reflects the other Python version rather than ours. |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
140 # Note that for target_version!=sys.version, we must have skipped the |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
141 # build step, so there is no issue with enforcing the build of this |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
142 # version. |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
143 target_version = self.target_version |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
144 if not target_version: |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
145 assert self.skip_build, "Should have already checked this" |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
146 target_version = sys.version[0:3] |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
147 plat_specifier = ".%s-%s" % (self.plat_name, target_version) |
|
33852
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
148 build = self.get_finalized_command('build') |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
149 build.build_lib = os.path.join(build.build_base, |
|
943862b2b4df
Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents:
33161
diff
changeset
|
150 'lib' + plat_specifier) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
151 |
|
19725
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
152 # Use a custom scheme for the zip-file, because we have to decide |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
153 # at installation time which scheme to use. |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
154 for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'): |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
155 value = string.upper(key) |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
156 if key == 'headers': |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
157 value = value + '/Include/$dist_name' |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
158 setattr(install, |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
159 'install_' + key, |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
160 value) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
161 |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22911
diff
changeset
|
162 log.info("installing to %s", self.bdist_dir) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
163 install.ensure_finalized() |
|
19725
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
164 |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
165 # avoid warning of 'install_lib' about installing |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
166 # into a directory not in sys.path |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
167 sys.path.insert(0, os.path.join(self.bdist_dir, 'PURELIB')) |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
168 |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
169 install.run() |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
170 |
|
19725
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
171 del sys.path[0] |
|
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
172 |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
173 # And make an archive relative to the root of the |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
174 # pseudo-installation tree. |
|
25795
ac14317a9ae8
Revert the previous checkin - it didn't work anyway.
Thomas Heller <theller@ctypes.org>
parents:
24710
diff
changeset
|
175 from tempfile import mktemp |
|
ac14317a9ae8
Revert the previous checkin - it didn't work anyway.
Thomas Heller <theller@ctypes.org>
parents:
24710
diff
changeset
|
176 archive_basename = mktemp() |
|
13350
e0d676e9cb66
Fixed so the ZIP file (which is bundled into an executable) goes in the
Greg Ward <gward@python.net>
parents:
13165
diff
changeset
|
177 fullname = self.distribution.get_fullname() |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
178 arcname = self.make_archive(archive_basename, "zip", |
|
19725
226d5eefa44a
Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents:
18383
diff
changeset
|
179 root_dir=self.bdist_dir) |
|
21470
959a2ed5735c
Second part of fix for bug [#483982] Python 2.2b2 bdist_wininst
Thomas Heller <theller@ctypes.org>
parents:
21268
diff
changeset
|
180 # create an exe containing the zip-file |
|
16675
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
181 self.create_exe(arcname, fullname, self.bitmap) |
|
34805
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34801
diff
changeset
|
182 if self.distribution.has_ext_modules(): |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34801
diff
changeset
|
183 pyversion = get_python_version() |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34801
diff
changeset
|
184 else: |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34801
diff
changeset
|
185 pyversion = 'any' |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34801
diff
changeset
|
186 self.distribution.dist_files.append(('bdist_wininst', pyversion, |
|
34801
cebfbab017a6
Fix registration of output file.
Martin v. Löwis <martin@v.loewis.de>
parents:
34793
diff
changeset
|
187 self.get_installer_filename(fullname))) |
|
21470
959a2ed5735c
Second part of fix for bug [#483982] Python 2.2b2 bdist_wininst
Thomas Heller <theller@ctypes.org>
parents:
21268
diff
changeset
|
188 # remove the zip-file again |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22911
diff
changeset
|
189 log.debug("removing temporary file '%s'", arcname) |
|
25795
ac14317a9ae8
Revert the previous checkin - it didn't work anyway.
Thomas Heller <theller@ctypes.org>
parents:
24710
diff
changeset
|
190 os.remove(arcname) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
191 |
|
14633
7d0e3450ee41
Renamed --keep-tree to --keep-temp.
Greg Ward <gward@python.net>
parents:
14496
diff
changeset
|
192 if not self.keep_temp: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22911
diff
changeset
|
193 remove_tree(self.bdist_dir, dry_run=self.dry_run) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
194 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
195 # run() |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
196 |
|
14324
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
197 def get_inidata (self): |
|
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
198 # Return data describing the installation. |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
199 |
|
14324
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
200 lines = [] |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
201 metadata = self.distribution.metadata |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
202 |
|
32803
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
203 # Write the [metadata] section. |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
204 lines.append("[metadata]") |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
205 |
|
13042
1f2441978ab1
Fixed to use 'reinitialize_command()' to fetch "install" and "install_lib"
Greg Ward <gward@python.net>
parents:
13031
diff
changeset
|
206 # 'info' will be displayed in the installer's dialog box, |
|
1f2441978ab1
Fixed to use 'reinitialize_command()' to fetch "install" and "install_lib"
Greg Ward <gward@python.net>
parents:
13031
diff
changeset
|
207 # describing the items to be installed. |
| 14233 | 208 info = (metadata.long_description or '') + '\n' |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
209 |
|
32803
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
210 # Escape newline characters |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
211 def escape(s): |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
212 return string.replace(s, "\n", "\\n") |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
213 |
|
20274
d7d956b47d24
Explicitely list the metadata attributes to show
Thomas Heller <theller@ctypes.org>
parents:
19725
diff
changeset
|
214 for name in ["author", "author_email", "description", "maintainer", |
|
d7d956b47d24
Explicitely list the metadata attributes to show
Thomas Heller <theller@ctypes.org>
parents:
19725
diff
changeset
|
215 "maintainer_email", "name", "url", "version"]: |
|
d7d956b47d24
Explicitely list the metadata attributes to show
Thomas Heller <theller@ctypes.org>
parents:
19725
diff
changeset
|
216 data = getattr(metadata, name, "") |
|
d7d956b47d24
Explicitely list the metadata attributes to show
Thomas Heller <theller@ctypes.org>
parents:
19725
diff
changeset
|
217 if data: |
|
d7d956b47d24
Explicitely list the metadata attributes to show
Thomas Heller <theller@ctypes.org>
parents:
19725
diff
changeset
|
218 info = info + ("\n %s: %s" % \ |
|
32803
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
219 (string.capitalize(name), escape(data))) |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
220 lines.append("%s=%s" % (name, escape(data))) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
221 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
222 # The [setup] section contains entries controlling |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
223 # the installer runtime. |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
224 lines.append("\n[Setup]") |
|
21987
0f63111bf4c5
First version which runs an install-script (specified by the
Thomas Heller <theller@ctypes.org>
parents:
21714
diff
changeset
|
225 if self.install_script: |
|
0f63111bf4c5
First version which runs an install-script (specified by the
Thomas Heller <theller@ctypes.org>
parents:
21714
diff
changeset
|
226 lines.append("install_script=%s" % self.install_script) |
|
32803
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
227 lines.append("info=%s" % escape(info)) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
228 lines.append("target_compile=%d" % (not self.no_target_compile)) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
229 lines.append("target_optimize=%d" % (not self.no_target_optimize)) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
230 if self.target_version: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
231 lines.append("target_version=%s" % self.target_version) |
|
46624
0ba12c32e2b5
#2581: Vista UAC/elevation support for bdist_wininst
Mark Hammond <mhammond@skippinet.com.au>
parents:
46331
diff
changeset
|
232 if self.user_access_control: |
|
0ba12c32e2b5
#2581: Vista UAC/elevation support for bdist_wininst
Mark Hammond <mhammond@skippinet.com.au>
parents:
46331
diff
changeset
|
233 lines.append("user_access_control=%s" % self.user_access_control) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
234 |
|
16675
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
235 title = self.title or self.distribution.get_fullname() |
|
32803
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
236 lines.append("title=%s" % escape(title)) |
|
14496
aed37f5aa475
The installer now displays info about version of distutils
Thomas Heller <theller@ctypes.org>
parents:
14495
diff
changeset
|
237 import time |
|
aed37f5aa475
The installer now displays info about version of distutils
Thomas Heller <theller@ctypes.org>
parents:
14495
diff
changeset
|
238 import distutils |
|
31565
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
239 build_info = "Built %s with distutils-%s" % \ |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
240 (time.ctime(time.time()), distutils.__version__) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
241 lines.append("build_info=%s" % build_info) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
242 return string.join(lines, "\n") |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
243 |
|
14324
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
244 # get_inidata() |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
245 |
|
16675
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
246 def create_exe (self, arcname, fullname, bitmap=None): |
|
14324
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
247 import struct |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
248 |
|
14324
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
249 self.mkpath(self.dist_dir) |
|
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
250 |
|
58842cba8dbc
Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents:
14233
diff
changeset
|
251 cfgdata = self.get_inidata() |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
252 |
|
32805
b8bc59578a47
Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents:
32803
diff
changeset
|
253 installer_name = self.get_installer_filename(fullname) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
254 self.announce("creating %s" % installer_name) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
255 |
|
16675
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
256 if bitmap: |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
257 bitmapdata = open(bitmap, "rb").read() |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
258 bitmaplen = len(bitmapdata) |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
259 else: |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
260 bitmaplen = 0 |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
261 |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
262 file = open(installer_name, "wb") |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
263 file.write(self.get_exe_bytes()) |
|
16675
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
264 if bitmap: |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
265 file.write(bitmapdata) |
| 21268 | 266 |
|
32803
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
267 # Convert cfgdata from unicode to ascii, mbcs encoded |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
268 try: |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
269 unicode |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
270 except NameError: |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
271 pass |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
272 else: |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
273 if isinstance(cfgdata, unicode): |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
274 cfgdata = cfgdata.encode("mbcs") |
|
dac28136d59b
bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents:
32755
diff
changeset
|
275 |
|
31565
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
276 # Append the pre-install script |
|
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
277 cfgdata = cfgdata + "\0" |
|
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
278 if self.pre_install_script: |
|
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
279 script_data = open(self.pre_install_script, "r").read() |
|
911b3215d0dc
Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents:
29427
diff
changeset
|
280 cfgdata = cfgdata + script_data + "\n\0" |
|
31571
78f758abc79f
Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents:
31565
diff
changeset
|
281 else: |
|
78f758abc79f
Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents:
31565
diff
changeset
|
282 # empty pre-install script |
|
78f758abc79f
Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents:
31565
diff
changeset
|
283 cfgdata = cfgdata + "\0" |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
284 file.write(cfgdata) |
|
32755
257563dcb442
The binary layout of cfgdata has changed, so the magic number has to
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
285 |
|
257563dcb442
The binary layout of cfgdata has changed, so the magic number has to
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
286 # The 'magic number' 0x1234567B is used to make sure that the |
|
257563dcb442
The binary layout of cfgdata has changed, so the magic number has to
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
287 # binary layout of 'cfgdata' is what the wininst.exe binary |
|
257563dcb442
The binary layout of cfgdata has changed, so the magic number has to
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
288 # expects. If the layout changes, increment that number, make |
|
257563dcb442
The binary layout of cfgdata has changed, so the magic number has to
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
289 # the corresponding changes to the wininst.exe sources, and |
|
257563dcb442
The binary layout of cfgdata has changed, so the magic number has to
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
290 # recompile them. |
|
16675
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
291 header = struct.pack("<iii", |
|
32755
257563dcb442
The binary layout of cfgdata has changed, so the magic number has to
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
292 0x1234567B, # tag |
|
16675
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
293 len(cfgdata), # length |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
294 bitmaplen, # number of bytes in bitmap |
|
963f95eb7646
Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents:
15180
diff
changeset
|
295 ) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
296 file.write(header) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14923
diff
changeset
|
297 file.write(open(arcname, "rb").read()) |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
298 |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
299 # create_exe() |
|
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
300 |
|
32805
b8bc59578a47
Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents:
32803
diff
changeset
|
301 def get_installer_filename(self, fullname): |
|
b8bc59578a47
Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents:
32803
diff
changeset
|
302 # Factored out to allow overriding in subclasses |
|
b8bc59578a47
Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents:
32803
diff
changeset
|
303 if self.target_version: |
|
b8bc59578a47
Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents:
32803
diff
changeset
|
304 # if we create an installer for a specific python version, |
|
b8bc59578a47
Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents:
32803
diff
changeset
|
305 # it's better to include this in the name |
|
b8bc59578a47
Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents:
32803
diff
changeset
|
306 installer_name = os.path.join(self.dist_dir, |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
307 "%s.%s-py%s.exe" % |
|
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
308 (fullname, self.plat_name, self.target_version)) |
|
32805
b8bc59578a47
Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents:
32803
diff
changeset
|
309 else: |
|
b8bc59578a47
Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents:
32803
diff
changeset
|
310 installer_name = os.path.join(self.dist_dir, |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
311 "%s.%s.exe" % (fullname, self.plat_name)) |
|
33161
bfb291f85871
The get_installer_filename() method forgot to return the name it
Thomas Heller <theller@ctypes.org>
parents:
32805
diff
changeset
|
312 return installer_name |
|
32805
b8bc59578a47
Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents:
32803
diff
changeset
|
313 # get_installer_filename() |
|
b8bc59578a47
Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents:
32803
diff
changeset
|
314 |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
315 def get_exe_bytes (self): |
|
31571
78f758abc79f
Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents:
31565
diff
changeset
|
316 from distutils.msvccompiler import get_build_version |
| 32511 | 317 # If a target-version other than the current version has been |
| 318 # specified, then using the MSVC version from *this* build is no good. | |
| 319 # Without actually finding and executing the target version and parsing | |
| 320 # its sys.version, we just hard-code our knowledge of old versions. | |
| 321 # NOTE: Possible alternative is to allow "--target-version" to | |
| 322 # specify a Python executable rather than a simple version string. | |
| 323 # We can then execute this program to obtain any info we need, such | |
| 324 # as the real sys.version string for the build. | |
| 325 cur_version = get_python_version() | |
| 326 if self.target_version and self.target_version != cur_version: | |
| 327 # If the target version is *later* than us, then we assume they | |
| 328 # use what we use | |
| 329 # string compares seem wrong, but are what sysconfig.py itself uses | |
| 330 if self.target_version > cur_version: | |
| 331 bv = get_build_version() | |
| 332 else: | |
| 333 if self.target_version < "2.4": | |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
334 bv = 6.0 |
| 32511 | 335 else: |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
336 bv = 7.1 |
| 32511 | 337 else: |
| 338 # for current version - use authoritative check. | |
| 339 bv = get_build_version() | |
| 340 | |
|
31571
78f758abc79f
Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents:
31565
diff
changeset
|
341 # wininst-x.y.exe is in the same directory as this file |
|
26359
54a74b0dfe26
(This is hopefully the last large, funny checkin message for
Thomas Heller <theller@ctypes.org>
parents:
26358
diff
changeset
|
342 directory = os.path.dirname(__file__) |
|
31571
78f758abc79f
Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents:
31565
diff
changeset
|
343 # we must use a wininst-x.y.exe built with the same C compiler |
|
78f758abc79f
Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents:
31565
diff
changeset
|
344 # used for python. XXX What about mingw, borland, and so on? |
|
53002
40eff3b182e4
Fixed #5731: Distutils bdist_wininst no longer worked on non-Windows platforms
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
345 |
|
40eff3b182e4
Fixed #5731: Distutils bdist_wininst no longer worked on non-Windows platforms
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
346 # if plat_name starts with "win" but is not "win32" |
|
40eff3b182e4
Fixed #5731: Distutils bdist_wininst no longer worked on non-Windows platforms
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
347 # we want to strip "win" and leave the rest (e.g. -amd64) |
|
40eff3b182e4
Fixed #5731: Distutils bdist_wininst no longer worked on non-Windows platforms
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
348 # for all other cases, we don't want any suffix |
|
40eff3b182e4
Fixed #5731: Distutils bdist_wininst no longer worked on non-Windows platforms
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
349 if self.plat_name != 'win32' and self.plat_name[:3] == 'win': |
|
40eff3b182e4
Fixed #5731: Distutils bdist_wininst no longer worked on non-Windows platforms
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
350 sfix = self.plat_name[3:] |
|
40eff3b182e4
Fixed #5731: Distutils bdist_wininst no longer worked on non-Windows platforms
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
351 else: |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
352 sfix = '' |
|
53002
40eff3b182e4
Fixed #5731: Distutils bdist_wininst no longer worked on non-Windows platforms
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
353 |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
44391
diff
changeset
|
354 filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix)) |
|
26359
54a74b0dfe26
(This is hopefully the last large, funny checkin message for
Thomas Heller <theller@ctypes.org>
parents:
26358
diff
changeset
|
355 return open(filename, "rb").read() |
|
13031
00a981194ca6
Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff
changeset
|
356 # class bdist_wininst |
