annotate Lib/distutils/command/bdist_wininst.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents 4ff92eb1a915
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
57847
3e2b7965ada9 massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53002
diff changeset
8 import sys
3e2b7965ada9 massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53002
diff changeset
9 import os
3e2b7965ada9 massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53002
diff changeset
10 import string
3e2b7965ada9 massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53002
diff changeset
11
58503
f9fd1795fcf7 added local get_platform/set_platform APIs in distutils.sysconfig
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58450
diff changeset
12 from sysconfig import get_python_version
58450
fa69e891edf4 taking sysconfig out of distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 57847
diff changeset
13
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
14 from distutils.core import Command
57847
3e2b7965ada9 massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53002
diff changeset
15 from distutils.dir_util import remove_tree
3e2b7965ada9 massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 53002
diff changeset
16 from distutils.errors import DistutilsOptionError, DistutilsPlatformError
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 22911
diff changeset
17 from distutils import log
13871
8307446bc6aa Fixed imports from '*util' modules to not just import everything from util.
Greg Ward <gward@python.net>
parents: 13350
diff changeset
18 from distutils.util import get_platform
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
19
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
20 class bdist_wininst (Command):
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
21
13042
1f2441978ab1 Fixed to use 'reinitialize_command()' to fetch "install" and "install_lib"
Greg Ward <gward@python.net>
parents: 13031
diff changeset
22 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
23
17060
3f5276cbbc4d The bdist_wininst.py command has been recreated after wininst.exe
Thomas Heller <theller@ctypes.org>
parents: 16675
diff changeset
24 user_options = [('bdist-dir=', None,
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
25 "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
26 ('plat-name=', 'p',
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 44391
diff changeset
27 "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
28 "(default: %s)" % get_platform()),
14633
7d0e3450ee41 Renamed --keep-tree to --keep-temp.
Greg Ward <gward@python.net>
parents: 14496
diff changeset
29 ('keep-temp', 'k',
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
30 "keep the pseudo-installation tree around after " +
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
31 "creating the distribution archive"),
32511
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
32 ('target-version=', None,
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
33 "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
34 " on the target system"),
14454
015a34bfbccb Changes:
Thomas Heller <theller@ctypes.org>
parents: 14324
diff changeset
35 ('no-target-compile', 'c',
015a34bfbccb Changes:
Thomas Heller <theller@ctypes.org>
parents: 14324
diff changeset
36 "do not compile .py to .pyc on the target system"),
015a34bfbccb Changes:
Thomas Heller <theller@ctypes.org>
parents: 14324
diff changeset
37 ('no-target-optimize', 'o',
14923
75f3d5e7b89c Removed the extra_dirs and path_file metadata options.
Thomas Heller <theller@ctypes.org>
parents: 14829
diff changeset
38 "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
39 "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
40 ('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
41 "directory to put final built distributions in"),
16675
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
42 ('bitmap=', 'b',
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
43 "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
44 ('title=', 't',
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
45 "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
46 ('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
47 "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
48 ('install-script=', None,
26034
183fc21fb866 Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents: 25805
diff changeset
49 "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
50 "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
51 ('pre-install-script=', None,
911b3215d0dc Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents: 29427
diff changeset
52 "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
53 "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
54 "distribution"),
46624
0ba12c32e2b5 #2581: Vista UAC/elevation support for bdist_wininst
Mark Hammond <mhammond@skippinet.com.au>
parents: 46331
diff changeset
55 ('user-access-control=', None,
0ba12c32e2b5 #2581: Vista UAC/elevation support for bdist_wininst
Mark Hammond <mhammond@skippinet.com.au>
parents: 46331
diff changeset
56 "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
57 "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
58 "all users, 'force'=always use UAC"),
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
59 ]
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
60
22434
c0ae6f46f231 Add unlisted Boolean options. Thomas H., can you please check that I
Andrew M. Kuchling <amk@amk.ca>
parents: 21987
diff changeset
61 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
62 'skip-build']
14829
b1f220f636ed Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents: 14745
diff changeset
63
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
64 def initialize_options (self):
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
65 self.bdist_dir = None
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 44391
diff changeset
66 self.plat_name = None
14633
7d0e3450ee41 Renamed --keep-tree to --keep-temp.
Greg Ward <gward@python.net>
parents: 14496
diff changeset
67 self.keep_temp = 0
14454
015a34bfbccb Changes:
Thomas Heller <theller@ctypes.org>
parents: 14324
diff changeset
68 self.no_target_compile = 0
015a34bfbccb Changes:
Thomas Heller <theller@ctypes.org>
parents: 14324
diff changeset
69 self.no_target_optimize = 0
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
70 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
71 self.dist_dir = None
16675
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
72 self.bitmap = None
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
73 self.title = None
72136
4ff92eb1a915 Make bdist_* commands respect --skip-build passed to bdist (#10946)
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
74 self.skip_build = None
21987
0f63111bf4c5 First version which runs an install-script (specified by the
Thomas Heller <theller@ctypes.org>
parents: 21714
diff changeset
75 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
76 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
77 self.user_access_control = None
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
78
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
79 # initialize_options()
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
80
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
81
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
82 def finalize_options (self):
72136
4ff92eb1a915 Make bdist_* commands respect --skip-build passed to bdist (#10946)
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
83 self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
4ff92eb1a915 Make bdist_* commands respect --skip-build passed to bdist (#10946)
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
84
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
85 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
86 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
87 # 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
88 # 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
89 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
90 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
91 # 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
92 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
93 self.bdist_dir = os.path.join(bdist_base, 'wininst')
72136
4ff92eb1a915 Make bdist_* commands respect --skip-build passed to bdist (#10946)
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
94
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
95 if not self.target_version:
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
96 self.target_version = ""
72136
4ff92eb1a915 Make bdist_* commands respect --skip-build passed to bdist (#10946)
Éric Araujo <merwok@netwok.org>
parents: 68256
diff changeset
97
31565
911b3215d0dc Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents: 29427
diff changeset
98 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
99 short_version = get_python_version()
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
100 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
101 raise DistutilsOptionError, \
63609
a9cd2550ff40 Merged revisions 83593 via svnmerge from
Georg Brandl <georg@python.org>
parents: 53011
diff changeset
102 "target version can only be %s, or the '--skip-build'" \
31565
911b3215d0dc Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents: 29427
diff changeset
103 " option must be specified" % (short_version,)
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
104 self.target_version = short_version
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
105
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 44391
diff changeset
106 self.set_undefined_options('bdist',
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 44391
diff changeset
107 ('dist_dir', 'dist_dir'),
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 44391
diff changeset
108 ('plat_name', 'plat_name'),
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 44391
diff changeset
109 )
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
110
26034
183fc21fb866 Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents: 25805
diff changeset
111 if self.install_script:
183fc21fb866 Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents: 25805
diff changeset
112 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
113 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
114 break
183fc21fb866 Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents: 25805
diff changeset
115 else:
183fc21fb866 Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents: 25805
diff changeset
116 raise DistutilsOptionError, \
183fc21fb866 Must now give the basename - not including directories - of the
Thomas Heller <theller@ctypes.org>
parents: 25805
diff changeset
117 "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
118 self.install_script
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
119 # finalize_options()
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
120
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
121
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
122 def run (self):
14324
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
123 if (sys.platform != "win32" and
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
124 (self.distribution.has_ext_modules() or
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
125 self.distribution.has_c_libraries())):
14454
015a34bfbccb Changes:
Thomas Heller <theller@ctypes.org>
parents: 14324
diff changeset
126 raise DistutilsPlatformError \
14324
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
127 ("distribution contains extensions and/or C libraries; "
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
128 "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
129
21714
630293be1035 Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents: 21472
diff changeset
130 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
131 self.run_command('build')
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
132
29427
edcfef944e2f Fix for sf # 749210, wininst isn't build correctly after building zip.
Thomas Heller <theller@ctypes.org>
parents: 26359
diff changeset
133 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
134 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
135 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
136 install.warn_dir = 0
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 44391
diff changeset
137 install.plat_name = self.plat_name
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
138
13042
1f2441978ab1 Fixed to use 'reinitialize_command()' to fetch "install" and "install_lib"
Greg Ward <gward@python.net>
parents: 13031
diff changeset
139 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
140 # 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
141 install_lib.compile = 0
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
142 install_lib.optimize = 0
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 32511
diff changeset
143
33852
943862b2b4df Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents: 33161
diff changeset
144 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
145 # 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
146 # 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
147 # 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
148 # 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
149 # 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
150 # version.
943862b2b4df Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents: 33161
diff changeset
151 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
152 if not target_version:
943862b2b4df Fix [1055540 ] bdist_wininst broken for pure Python distributions
Mark Hammond <mhammond@skippinet.com.au>
parents: 33161
diff changeset
153 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
154 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
155 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
156 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
157 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
158 'lib' + plat_specifier)
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
159
19725
226d5eefa44a Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents: 18383
diff changeset
160 # 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
161 # 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
162 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
163 value = string.upper(key)
226d5eefa44a Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents: 18383
diff changeset
164 if key == 'headers':
226d5eefa44a Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents: 18383
diff changeset
165 value = value + '/Include/$dist_name'
226d5eefa44a Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents: 18383
diff changeset
166 setattr(install,
226d5eefa44a Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents: 18383
diff changeset
167 'install_' + key,
226d5eefa44a Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents: 18383
diff changeset
168 value)
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
169
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 22911
diff changeset
170 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
171 install.ensure_finalized()
19725
226d5eefa44a Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents: 18383
diff changeset
172
226d5eefa44a Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents: 18383
diff changeset
173 # 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
174 # 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
175 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
176
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
177 install.run()
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
178
19725
226d5eefa44a Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents: 18383
diff changeset
179 del sys.path[0]
226d5eefa44a Implement PEP250: Use Lib/site-packages under windows.
Thomas Heller <theller@ctypes.org>
parents: 18383
diff changeset
180
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
181 # 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
182 # pseudo-installation tree.
25795
ac14317a9ae8 Revert the previous checkin - it didn't work anyway.
Thomas Heller <theller@ctypes.org>
parents: 24710
diff changeset
183 from tempfile import mktemp
ac14317a9ae8 Revert the previous checkin - it didn't work anyway.
Thomas Heller <theller@ctypes.org>
parents: 24710
diff changeset
184 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
185 fullname = self.distribution.get_fullname()
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
186 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
187 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
188 # create an exe containing the zip-file
16675
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
189 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
190 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
191 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
192 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
193 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
194 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
195 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
196 # remove the zip-file again
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 22911
diff changeset
197 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
198 os.remove(arcname)
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
199
14633
7d0e3450ee41 Renamed --keep-tree to --keep-temp.
Greg Ward <gward@python.net>
parents: 14496
diff changeset
200 if not self.keep_temp:
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 22911
diff changeset
201 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
202
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
203 # run()
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
204
14324
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
205 def get_inidata (self):
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
206 # Return data describing the installation.
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
207
14324
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
208 lines = []
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
209 metadata = self.distribution.metadata
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
210
32803
dac28136d59b bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents: 32755
diff changeset
211 # Write the [metadata] section.
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
212 lines.append("[metadata]")
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
213
13042
1f2441978ab1 Fixed to use 'reinitialize_command()' to fetch "install" and "install_lib"
Greg Ward <gward@python.net>
parents: 13031
diff changeset
214 # '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
215 # describing the items to be installed.
14233
b97e6202f0b1 Fix line-endings.
Greg Ward <gward@python.net>
parents: 14218
diff changeset
216 info = (metadata.long_description or '') + '\n'
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
217
32803
dac28136d59b bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents: 32755
diff changeset
218 # Escape newline characters
dac28136d59b bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents: 32755
diff changeset
219 def escape(s):
dac28136d59b bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents: 32755
diff changeset
220 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
221
20274
d7d956b47d24 Explicitely list the metadata attributes to show
Thomas Heller <theller@ctypes.org>
parents: 19725
diff changeset
222 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
223 "maintainer_email", "name", "url", "version"]:
d7d956b47d24 Explicitely list the metadata attributes to show
Thomas Heller <theller@ctypes.org>
parents: 19725
diff changeset
224 data = getattr(metadata, name, "")
d7d956b47d24 Explicitely list the metadata attributes to show
Thomas Heller <theller@ctypes.org>
parents: 19725
diff changeset
225 if data:
d7d956b47d24 Explicitely list the metadata attributes to show
Thomas Heller <theller@ctypes.org>
parents: 19725
diff changeset
226 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
227 (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
228 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
229
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
230 # The [setup] section contains entries controlling
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
231 # the installer runtime.
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
232 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
233 if self.install_script:
0f63111bf4c5 First version which runs an install-script (specified by the
Thomas Heller <theller@ctypes.org>
parents: 21714
diff changeset
234 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
235 lines.append("info=%s" % escape(info))
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
236 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
237 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
238 if self.target_version:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
239 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
240 if self.user_access_control:
0ba12c32e2b5 #2581: Vista UAC/elevation support for bdist_wininst
Mark Hammond <mhammond@skippinet.com.au>
parents: 46331
diff changeset
241 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
242
16675
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
243 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
244 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
245 import time
aed37f5aa475 The installer now displays info about version of distutils
Thomas Heller <theller@ctypes.org>
parents: 14495
diff changeset
246 import distutils
31565
911b3215d0dc Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents: 29427
diff changeset
247 build_info = "Built %s with distutils-%s" % \
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
248 (time.ctime(time.time()), distutils.__version__)
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
249 lines.append("build_info=%s" % build_info)
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
250 return string.join(lines, "\n")
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
251
14324
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
252 # get_inidata()
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
253
16675
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
254 def create_exe (self, arcname, fullname, bitmap=None):
14324
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
255 import struct
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
256
14324
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
257 self.mkpath(self.dist_dir)
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
258
58842cba8dbc Rene Liebscher/Thomas Heller:
Greg Ward <gward@python.net>
parents: 14233
diff changeset
259 cfgdata = self.get_inidata()
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
260
32805
b8bc59578a47 Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents: 32803
diff changeset
261 installer_name = self.get_installer_filename(fullname)
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
262 self.announce("creating %s" % installer_name)
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
263
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 bitmapdata = open(bitmap, "rb").read()
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
266 bitmaplen = len(bitmapdata)
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
267 else:
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
268 bitmaplen = 0
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
269
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
270 file = open(installer_name, "wb")
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
271 file.write(self.get_exe_bytes())
16675
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
272 if bitmap:
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
273 file.write(bitmapdata)
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 20274
diff changeset
274
32803
dac28136d59b bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents: 32755
diff changeset
275 # 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
276 try:
dac28136d59b bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents: 32755
diff changeset
277 unicode
dac28136d59b bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents: 32755
diff changeset
278 except NameError:
dac28136d59b bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents: 32755
diff changeset
279 pass
dac28136d59b bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents: 32755
diff changeset
280 else:
dac28136d59b bdist_wininst does now properly handle unicode strings or byte strings
Thomas Heller <theller@ctypes.org>
parents: 32755
diff changeset
281 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
282 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
283
31565
911b3215d0dc Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents: 29427
diff changeset
284 # 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
285 cfgdata = cfgdata + "\0"
911b3215d0dc Patch #892660 from Mark Hammond, for distutils bdist_wininst command.
Thomas Heller <theller@ctypes.org>
parents: 29427
diff changeset
286 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
287 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
288 cfgdata = cfgdata + script_data + "\n\0"
31571
78f758abc79f Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents: 31565
diff changeset
289 else:
78f758abc79f Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents: 31565
diff changeset
290 # empty pre-install script
78f758abc79f Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents: 31565
diff changeset
291 cfgdata = cfgdata + "\0"
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
292 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
293
257563dcb442 The binary layout of cfgdata has changed, so the magic number has to
Thomas Heller <theller@ctypes.org>
parents: 32736
diff changeset
294 # 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
295 # 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
296 # 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
297 # 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
298 # recompile them.
16675
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
299 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
300 0x1234567B, # tag
16675
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
301 len(cfgdata), # length
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
302 bitmaplen, # number of bytes in bitmap
963f95eb7646 Enhancements to the bdist_wininst command:
Thomas Heller <theller@ctypes.org>
parents: 15180
diff changeset
303 )
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
304 file.write(header)
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14923
diff changeset
305 file.write(open(arcname, "rb").read())
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
306
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
307 # create_exe()
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
308
32805
b8bc59578a47 Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents: 32803
diff changeset
309 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
310 # 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
311 if self.target_version:
b8bc59578a47 Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents: 32803
diff changeset
312 # 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
313 # 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
314 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
315 "%s.%s-py%s.exe" %
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 44391
diff changeset
316 (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
317 else:
b8bc59578a47 Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents: 32803
diff changeset
318 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
319 "%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
320 return installer_name
32805
b8bc59578a47 Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents: 32803
diff changeset
321 # get_installer_filename()
b8bc59578a47 Factored out a method to determine the final installer filename.
Thomas Heller <theller@ctypes.org>
parents: 32803
diff changeset
322
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
323 def get_exe_bytes (self):
31571
78f758abc79f Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents: 31565
diff changeset
324 from distutils.msvccompiler import get_build_version
32511
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
325 # If a target-version other than the current version has been
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
326 # specified, then using the MSVC version from *this* build is no good.
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
327 # Without actually finding and executing the target version and parsing
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
328 # its sys.version, we just hard-code our knowledge of old versions.
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
329 # NOTE: Possible alternative is to allow "--target-version" to
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
330 # specify a Python executable rather than a simple version string.
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
331 # We can then execute this program to obtain any info we need, such
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
332 # as the real sys.version string for the build.
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
333 cur_version = get_python_version()
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
334 if self.target_version and self.target_version != cur_version:
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
335 # If the target version is *later* than us, then we assume they
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
336 # use what we use
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
337 # string compares seem wrong, but are what sysconfig.py itself uses
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
338 if self.target_version > cur_version:
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
339 bv = get_build_version()
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
340 else:
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
341 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
342 bv = 6.0
32511
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
343 else:
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 44391
diff changeset
344 bv = 7.1
32511
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
345 else:
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
346 # for current version - use authoritative check.
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
347 bv = get_build_version()
8e7c91de9491 Fix SF#983164.
Thomas Heller <theller@ctypes.org>
parents: 31571
diff changeset
348
31571
78f758abc79f Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents: 31565
diff changeset
349 # 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
350 directory = os.path.dirname(__file__)
31571
78f758abc79f Use the right wininstXX.exe, depending on
Thomas Heller <theller@ctypes.org>
parents: 31565
diff changeset
351 # 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
352 # used for python. XXX What about mingw, borland, and so on?
53011
79e57c866b5f Merged revisions 71413 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 47356
diff changeset
353
79e57c866b5f Merged revisions 71413 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 47356
diff changeset
354 # if plat_name starts with "win" but is not "win32"
79e57c866b5f Merged revisions 71413 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 47356
diff changeset
355 # we want to strip "win" and leave the rest (e.g. -amd64)
79e57c866b5f Merged revisions 71413 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 47356
diff changeset
356 # for all other cases, we don't want any suffix
79e57c866b5f Merged revisions 71413 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 47356
diff changeset
357 if self.plat_name != 'win32' and self.plat_name[:3] == 'win':
79e57c866b5f Merged revisions 71413 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 47356
diff changeset
358 sfix = self.plat_name[3:]
79e57c866b5f Merged revisions 71413 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 47356
diff changeset
359 else:
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 44391
diff changeset
360 sfix = ''
53011
79e57c866b5f Merged revisions 71413 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 47356
diff changeset
361
46331
a93d2919ea59 Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents: 44391
diff changeset
362 filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix))
66008
a17b21c27a33 Merged revisions 86223-86224,86226,86234 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 63608
diff changeset
363 f = open(filename, "rb")
a17b21c27a33 Merged revisions 86223-86224,86226,86234 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 63608
diff changeset
364 try:
a17b21c27a33 Merged revisions 86223-86224,86226,86234 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 63608
diff changeset
365 return f.read()
a17b21c27a33 Merged revisions 86223-86224,86226,86234 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 63608
diff changeset
366 finally:
a17b21c27a33 Merged revisions 86223-86224,86226,86234 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 63608
diff changeset
367 f.close()
13031
00a981194ca6 Thomas Heller's "bdist_wininst" command (unreviewed, untested).
Greg Ward <gward@python.net>
parents:
diff changeset
368 # class bdist_wininst