mirror of
https://github.com/python/cpython.git
synced 2025-09-09 18:32:22 +00:00
Fixed to use 'reinitialize_command()' to fetch "install" and "install_lib"
command objects. Various formatting tweaks, typo fixes in comments.
This commit is contained in:
parent
edc6a519dc
commit
b0b98a5ee5
1 changed files with 20 additions and 28 deletions
|
@ -7,14 +7,14 @@ exe-program."""
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os, sys
|
import sys, os, string
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.util import get_platform, create_tree, remove_tree
|
from distutils.util import get_platform, create_tree, remove_tree
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
|
|
||||||
class bdist_wininst (Command):
|
class bdist_wininst (Command):
|
||||||
|
|
||||||
description = "create a \"wininst\" built distribution"
|
description = "create an executable installer for MS Windows"
|
||||||
|
|
||||||
user_options = [('bdist-dir=', 'd',
|
user_options = [('bdist-dir=', 'd',
|
||||||
"temporary directory for creating the distribution"),
|
"temporary directory for creating the distribution"),
|
||||||
|
@ -64,22 +64,15 @@ class bdist_wininst (Command):
|
||||||
|
|
||||||
self.run_command ('build')
|
self.run_command ('build')
|
||||||
|
|
||||||
# XXX don't use 'self.get_finalized_command()', because it always
|
install = self.reinitialize_command('install')
|
||||||
# runs 'ensure_finalized()' on the command object; we explictly
|
|
||||||
# want a command object that has *not* been finalized, so we can set
|
|
||||||
# options on it! (The option we set, 'root', is so that we can do
|
|
||||||
# a proper "fake install" using this install command object.)
|
|
||||||
install = self.distribution.get_command_obj('install')
|
|
||||||
install.root = self.bdist_dir
|
install.root = self.bdist_dir
|
||||||
|
|
||||||
install_lib = self.distribution.get_command_obj('install_lib')
|
install_lib = self.reinitialize_command('install_lib')
|
||||||
|
|
||||||
install_lib.compile = 0
|
install_lib.compile = 0
|
||||||
install_lib.optimize = 0
|
install_lib.optimize = 0
|
||||||
|
|
||||||
# The packager (correct term in distutils speak?) can choose
|
# The packager can choose if .pyc and .pyo files should be created
|
||||||
# if pyc and pyo files should be created on the TARGET system
|
# on the TARGET system instead at the SOURCE system.
|
||||||
# instead at the SOURCE system.
|
|
||||||
|
|
||||||
## # The compilation can only be done on the SOURCE system
|
## # The compilation can only be done on the SOURCE system
|
||||||
## # for one python version (assuming 1.6 and 1.5 have incompatible
|
## # for one python version (assuming 1.6 and 1.5 have incompatible
|
||||||
|
@ -95,7 +88,6 @@ class bdist_wininst (Command):
|
||||||
|
|
||||||
self.announce ("installing to %s" % self.bdist_dir)
|
self.announce ("installing to %s" % self.bdist_dir)
|
||||||
install.ensure_finalized()
|
install.ensure_finalized()
|
||||||
|
|
||||||
install.run()
|
install.run()
|
||||||
|
|
||||||
# And make an archive relative to the root of the
|
# And make an archive relative to the root of the
|
||||||
|
@ -103,10 +95,14 @@ class bdist_wininst (Command):
|
||||||
archive_basename = "%s.win32" % self.distribution.get_fullname()
|
archive_basename = "%s.win32" % self.distribution.get_fullname()
|
||||||
# XXX hack! Our archive MUST be relative to sys.prefix
|
# XXX hack! Our archive MUST be relative to sys.prefix
|
||||||
# XXX What about .install_data, .install_scripts, ...?
|
# XXX What about .install_data, .install_scripts, ...?
|
||||||
|
# [Perhaps require that all installation dirs be under sys.prefix
|
||||||
|
# on Windows? this will be acceptable until we start dealing
|
||||||
|
# with Python applications, at which point we should zip up
|
||||||
|
# the application directory -- and again everything can be
|
||||||
|
# under one dir --GPW]
|
||||||
root_dir = install.install_lib
|
root_dir = install.install_lib
|
||||||
arcname = self.make_archive (archive_basename, "zip",
|
arcname = self.make_archive (archive_basename, "zip",
|
||||||
root_dir=root_dir)
|
root_dir=root_dir)
|
||||||
|
|
||||||
self.create_exe (arcname)
|
self.create_exe (arcname)
|
||||||
|
|
||||||
if not self.keep_tree:
|
if not self.keep_tree:
|
||||||
|
@ -115,26 +111,23 @@ class bdist_wininst (Command):
|
||||||
# run()
|
# run()
|
||||||
|
|
||||||
def create_inifile (self):
|
def create_inifile (self):
|
||||||
# create an inifile containing data describing the installation.
|
# Create an inifile containing data describing the installation.
|
||||||
# This could be done without creating a real file, but
|
# This could be done without creating a real file, but
|
||||||
# a file is (at least) usefull for debugging bdist_wininst.
|
# a file is (at least) useful for debugging bdist_wininst.
|
||||||
import string
|
|
||||||
|
|
||||||
metadata = self.distribution.metadata
|
metadata = self.distribution.metadata
|
||||||
|
ini_name = "%s.ini" % metadata.get_fullname()
|
||||||
ini_name = "%s.ini" % self.distribution.get_fullname()
|
|
||||||
|
|
||||||
self.announce ("creating %s" % ini_name)
|
self.announce ("creating %s" % ini_name)
|
||||||
|
|
||||||
inifile = open (ini_name, "w")
|
inifile = open (ini_name, "w")
|
||||||
|
|
||||||
# write the [metadata] section. values are written with repr()[1:],
|
# Write the [metadata] section. Values are written with
|
||||||
# so they do not contain unprintable characters, and are not
|
# repr()[1:-1], so they do not contain unprintable characters, and
|
||||||
# surrounded by quote chars
|
# are not surrounded by quote chars.
|
||||||
inifile.write ("[metadata]\n")
|
inifile.write ("[metadata]\n")
|
||||||
|
|
||||||
# 'info' will be displayed in the installers dialog box,
|
# 'info' will be displayed in the installer's dialog box,
|
||||||
# describing the items to be installed
|
# describing the items to be installed.
|
||||||
info = metadata.long_description + '\n'
|
info = metadata.long_description + '\n'
|
||||||
|
|
||||||
for name in dir (metadata):
|
for name in dir (metadata):
|
||||||
|
@ -173,7 +166,6 @@ class bdist_wininst (Command):
|
||||||
zcfgdata = co.compress (cfgdata) + co.flush()
|
zcfgdata = co.compress (cfgdata) + co.flush()
|
||||||
|
|
||||||
installer_name = "%s.win32.exe" % self.distribution.get_fullname()
|
installer_name = "%s.win32.exe" % self.distribution.get_fullname()
|
||||||
|
|
||||||
self.announce ("creating %s" % installer_name)
|
self.announce ("creating %s" % installer_name)
|
||||||
|
|
||||||
file = open (installer_name, "wb")
|
file = open (installer_name, "wb")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue