Added 'description' class attribute to every command class (to help the

'--help-commands' option).
Shuffled imports around in a few command modules to avoid expensive
  up-front import of sysconfig (and resulting delays in generating list
  of all commands).
This commit is contained in:
Greg Ward 2000-01-30 18:34:15 +00:00
parent 4c67936e4e
commit 37bc815053
8 changed files with 26 additions and 6 deletions

View file

@ -12,6 +12,8 @@ from distutils.core import Command
class Build (Command): class Build (Command):
description = "build everything needed to install"
options = [('build-base=', 'b', options = [('build-base=', 'b',
"base directory for build library"), "base directory for build library"),
('build-lib=', 'l', ('build-lib=', 'l',

View file

@ -11,8 +11,6 @@ __rcsid__ = "$Id$"
import sys, os, string, re import sys, os, string, re
from types import * from types import *
from distutils.core import Command from distutils.core import Command
from distutils.ccompiler import new_compiler
from distutils.sysconfig import INCLUDEPY, SO, exec_prefix
from distutils.errors import * from distutils.errors import *
@ -24,6 +22,8 @@ extension_name_re = re.compile \
class BuildExt (Command): class BuildExt (Command):
description = "build C/C++ extensions (compile/link to build directory)"
# XXX thoughts on how to deal with complex command-line options like # XXX thoughts on how to deal with complex command-line options like
# these, i.e. how to make it so fancy_getopt can suck them off the # these, i.e. how to make it so fancy_getopt can suck them off the
# command line and make it look like setup.py defined the appropriate # command line and make it look like setup.py defined the appropriate
@ -76,6 +76,8 @@ class BuildExt (Command):
def set_final_options (self): def set_final_options (self):
from distutils import sysconfig
self.set_undefined_options ('build', ('build_platlib', 'build_dir')) self.set_undefined_options ('build', ('build_platlib', 'build_dir'))
if self.package is None: if self.package is None:
@ -88,8 +90,8 @@ class BuildExt (Command):
# etc.) are in the include search path. We have to roll our own # etc.) are in the include search path. We have to roll our own
# "exec include dir", because the Makefile parsed by sysconfig # "exec include dir", because the Makefile parsed by sysconfig
# doesn't have it (sigh). # doesn't have it (sigh).
py_include = INCLUDEPY # prefix + "include" + "python" + ver py_include = sysconfig.INCLUDEPY # prefix + "include" + "python" + ver
exec_py_include = os.path.join (exec_prefix, 'include', exec_py_include = os.path.join (sysconfig.exec_prefix, 'include',
'python' + sys.version[0:3]) 'python' + sys.version[0:3])
if self.include_dirs is None: if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or [] self.include_dirs = self.distribution.include_dirs or []
@ -104,6 +106,8 @@ class BuildExt (Command):
def run (self): def run (self):
from distutils.ccompiler import new_compiler
# 'self.extensions', as supplied by setup.py, is a list of 2-tuples. # 'self.extensions', as supplied by setup.py, is a list of 2-tuples.
# Each tuple is simple: # Each tuple is simple:
# (ext_name, build_info) # (ext_name, build_info)
@ -246,9 +250,10 @@ class BuildExt (Command):
def extension_filename (self, ext_name, package=None): def extension_filename (self, ext_name, package=None):
from distutils import sysconfig
if package: if package:
ext_name = package + '.' + ext_name ext_name = package + '.' + ext_name
ext_path = string.split (ext_name, '.') ext_path = string.split (ext_name, '.')
return apply (os.path.join, ext_path) + SO return apply (os.path.join, ext_path) + sysconfig.SO
# class BuildExt # class BuildExt

View file

@ -16,6 +16,8 @@ from distutils.errors import *
class BuildPy (Command): class BuildPy (Command):
description = "\"build\" pure Python modules (copy to build directory)"
options = [('build-dir=', 'd', "directory for platform-shared files"), options = [('build-dir=', 'd', "directory for platform-shared files"),
] ]

View file

@ -131,6 +131,8 @@ from distutils.errors import DistutilsExecError
class Dist (Command): class Dist (Command):
description = "create a source distribution (tarball, zip file, etc.)"
options = [('formats=', None, options = [('formats=', None,
"formats for source distribution (tar, ztar, gztar, or zip)"), "formats for source distribution (tar, ztar, gztar, or zip)"),
('manifest=', 'm', ('manifest=', 'm',

View file

@ -8,13 +8,14 @@ __rcsid__ = "$Id$"
import sys, os, string import sys, os, string
from types import * from types import *
from distutils import sysconfig
from distutils.core import Command from distutils.core import Command
from distutils.util import write_file from distutils.util import write_file
class Install (Command): class Install (Command):
description = "install everything from build directory"
options = [('prefix=', None, "installation prefix"), options = [('prefix=', None, "installation prefix"),
('exec-prefix=', None, ('exec-prefix=', None,
"prefix for platform-specific files"), "prefix for platform-specific files"),
@ -246,6 +247,8 @@ class Install (Command):
then replace it with the current installation prefix and then replace it with the current installation prefix and
return the "relocated" installation directory.""" return the "relocated" installation directory."""
from distutils import sysconfig
if use_exec: if use_exec:
sys_prefix = os.path.normpath (sys.exec_prefix) sys_prefix = os.path.normpath (sys.exec_prefix)
my_prefix = self.exec_prefix my_prefix = self.exec_prefix

View file

@ -11,6 +11,8 @@ from distutils.util import copy_tree
class InstallExt (Command): class InstallExt (Command):
description = "install C/C++ extension modules"
options = [('install-dir=', 'd', "directory to install to"), options = [('install-dir=', 'd', "directory to install to"),
('build-dir=','b', "build directory (where to install from)"), ('build-dir=','b', "build directory (where to install from)"),
] ]

View file

@ -8,6 +8,8 @@ from distutils.util import copy_tree
class InstallPy (Command): class InstallPy (Command):
description = "install pure Python modules"
options = [('install-dir=', 'd', "directory to install to"), options = [('install-dir=', 'd', "directory to install to"),
('build-dir=','b', "build directory (where to install from)"), ('build-dir=','b', "build directory (where to install from)"),
('compile', 'c', "compile .py to .pyc"), ('compile', 'c', "compile .py to .pyc"),

View file

@ -8,6 +8,8 @@ from distutils.util import copy_tree
class InstallPy (Command): class InstallPy (Command):
description = "install pure Python modules"
options = [('install-dir=', 'd', "directory to install to"), options = [('install-dir=', 'd', "directory to install to"),
('build-dir=','b', "build directory (where to install from)"), ('build-dir=','b', "build directory (where to install from)"),
('compile', 'c', "compile .py to .pyc"), ('compile', 'c', "compile .py to .pyc"),