install.py 26.1 KB
Newer Older
1 2 3 4
"""distutils.command.install

Implements the Distutils 'install' command."""

5 6
from distutils import log

7
# This module should be kept compatible with Python 2.1.
8

9
__revision__ = "$Id$"
10 11

import sys, os, string
12
from types import *
13 14
from distutils.core import Command
from distutils.debug import DEBUG
15
from distutils.sysconfig import get_config_vars
16
from distutils.errors import DistutilsPlatformError
17 18
from distutils.file_util import write_file
from distutils.util import convert_path, subst_vars, change_root
19
from distutils.util import get_platform
20
from distutils.errors import DistutilsOptionError
Christian Heimes's avatar
Christian Heimes committed
21 22 23
from site import USER_BASE
from site import USER_SITE

24

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
if sys.version < "2.2":
    WINDOWS_SCHEME = {
        'purelib': '$base',
        'platlib': '$base',
        'headers': '$base/Include/$dist_name',
        'scripts': '$base/Scripts',
        'data'   : '$base',
    }
else:
    WINDOWS_SCHEME = {
        'purelib': '$base/Lib/site-packages',
        'platlib': '$base/Lib/site-packages',
        'headers': '$base/Include/$dist_name',
        'scripts': '$base/Scripts',
        'data'   : '$base',
    }

42 43 44 45
INSTALL_SCHEMES = {
    'unix_prefix': {
        'purelib': '$base/lib/python$py_version_short/site-packages',
        'platlib': '$platbase/lib/python$py_version_short/site-packages',
46
        'headers': '$base/include/python$py_version_short/$dist_name',
47
        'scripts': '$base/bin',
48
        'data'   : '$base',
49 50 51 52
        },
    'unix_home': {
        'purelib': '$base/lib/python',
        'platlib': '$base/lib/python',
53
        'headers': '$base/include/python/$dist_name',
54
        'scripts': '$base/bin',
55
        'data'   : '$base',
56
        },
Christian Heimes's avatar
Christian Heimes committed
57 58 59 60 61 62 63
    'unix_user': {
        'purelib': '$usersite',
        'platlib': '$usersite',
        'headers': '$userbase/include/python$py_version_short/$dist_name',
        'scripts': '$userbase/bin',
        'data'   : '$userbase',
        },
64
    'nt': WINDOWS_SCHEME,
Christian Heimes's avatar
Christian Heimes committed
65 66 67 68 69 70 71
    'nt_user': {
        'purelib': '$usersite',
        'platlib': '$usersite',
        'headers': '$userbase/Python$py_version_nodot/Include/$dist_name',
        'scripts': '$userbase/Scripts',
        'data'   : '$userbase',
        },
72
    'mac': {
73 74 75 76 77 78
        'purelib': '$base/Lib/site-packages',
        'platlib': '$base/Lib/site-packages',
        'headers': '$base/Include/$dist_name',
        'scripts': '$base/Scripts',
        'data'   : '$base',
        },
Christian Heimes's avatar
Christian Heimes committed
79 80 81 82 83 84 85
    'mac_user': {
        'purelib': '$usersite',
        'platlib': '$usersite',
        'headers': '$userbase/$py_version_short/include/$dist_name',
        'scripts': '$userbase/bin',
        'data'   : '$userbase',
        },
86
    'os2': {
87 88 89 90
        'purelib': '$base/Lib/site-packages',
        'platlib': '$base/Lib/site-packages',
        'headers': '$base/Include/$dist_name',
        'scripts': '$base/Scripts',
91
        'data'   : '$base',
Christian Heimes's avatar
Christian Heimes committed
92 93 94 95 96 97 98 99
        },
    'os2_home': {
        'purelib': '$usersite',
        'platlib': '$usersite',
        'headers': '$userbase/include/python$py_version_short/$dist_name',
        'scripts': '$userbase/bin',
        'data'   : '$userbase',
        },
100 101
    }

102 103 104 105 106
# The keys to an installation scheme; if any new types of files are to be
# installed, be sure to add an entry to every installation scheme above,
# and to SCHEME_KEYS here.
SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data')

107

108
class install (Command):
109

110 111
    description = "install everything from build directory"

112
    user_options = [
113 114 115
        # Select installation scheme and set base director(y|ies)
        ('prefix=', None,
         "installation prefix"),
116
        ('exec-prefix=', None,
117 118 119
         "(Unix only) prefix for platform-specific files"),
        ('home=', None,
         "(Unix only) home directory to install under"),
Christian Heimes's avatar
Christian Heimes committed
120 121
        ('user', None,
         "install in user site-package '%s'" % USER_SITE),
122 123 124 125 126 127 128

        # Or, just set the base director(y|ies)
        ('install-base=', None,
         "base installation directory (instead of --prefix or --home)"),
        ('install-platbase=', None,
         "base installation directory for platform-specific files " +
         "(instead of --exec-prefix or --home)"),
129 130
        ('root=', None,
         "install everything relative to this alternate root directory"),
131 132 133 134

        # Or, explicitly set the installation scheme
        ('install-purelib=', None,
         "installation directory for pure Python module distributions"),
135
        ('install-platlib=', None,
136 137 138 139 140
         "installation directory for non-pure module distributions"),
        ('install-lib=', None,
         "installation directory for all module distributions " +
         "(overrides --install-purelib and --install-platlib)"),

141 142
        ('install-headers=', None,
         "installation directory for C/C++ headers"),
143 144 145 146
        ('install-scripts=', None,
         "installation directory for Python scripts"),
        ('install-data=', None,
         "installation directory for data files"),
147

148 149 150 151 152 153 154 155
        # Byte-compilation options -- see install_lib.py for details, as
        # these are duplicated from there (but only install_lib does
        # anything with them).
        ('compile', 'c', "compile .py to .pyc [default]"),
        ('no-compile', None, "don't compile .py files"),
        ('optimize=', 'O',
         "also compile with optimization: -O1 for \"python -O\", "
         "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"),
Fred Drake's avatar
Fred Drake committed
156

157 158 159
        # Miscellaneous control options
        ('force', 'f',
         "force installation (overwrite any existing files)"),
160 161 162
        ('skip-build', None,
         "skip rebuilding everything (for testing/debugging)"),

163
        # Where to install documentation (eventually!)
164 165 166 167
        #('doc-format=', None, "format of documentation to generate"),
        #('install-man=', None, "directory for Unix man pages"),
        #('install-html=', None, "directory for HTML documentation"),
        #('install-info=', None, "directory for GNU info files"),
168

169 170
        ('record=', None,
         "filename in which to record list of installed files"),
171
        ]
172

Christian Heimes's avatar
Christian Heimes committed
173
    boolean_options = ['compile', 'force', 'skip-build', 'user']
174
    negative_opt = {'no-compile' : 'compile'}
175

176

177
    def initialize_options (self):
178

179 180
        # High-level options: these select both an installation base
        # and scheme.
181 182
        self.prefix = None
        self.exec_prefix = None
183
        self.home = None
Christian Heimes's avatar
Christian Heimes committed
184
        self.user = 0
185

186 187 188
        # These select only the installation base; it's up to the user to
        # specify the installation scheme (currently, that means supplying
        # the --install-{platlib,purelib,scripts,data} options).
189 190
        self.install_base = None
        self.install_platbase = None
191
        self.root = None
192

193 194 195 196 197 198
        # These options are the actual installation directories; if not
        # supplied by the user, they are filled in using the installation
        # scheme implied by prefix/exec-prefix/home and the contents of
        # that installation scheme.
        self.install_purelib = None     # for pure module distributions
        self.install_platlib = None     # non-pure (dists w/ extensions)
199
        self.install_headers = None     # for C/C++ headers
200
        self.install_lib = None         # set to either purelib or platlib
201 202
        self.install_scripts = None
        self.install_data = None
Christian Heimes's avatar
Christian Heimes committed
203 204
        self.install_userbase = USER_BASE
        self.install_usersite = USER_SITE
205

206
        self.compile = None
207 208
        self.optimize = None

209 210
        # These two are for putting non-packagized distributions into their
        # own directory and creating a .pth file if it makes sense.
211 212 213 214 215 216
        # 'extra_path' comes from the setup file; 'install_path_file' can
        # be turned off if it makes no sense to install a .pth file.  (But
        # better to install it uselessly than to guess wrong and not
        # install it when it's necessary and would be used!)  Currently,
        # 'install_path_file' is always true unless some outsider meddles
        # with it.
217
        self.extra_path = None
218 219 220 221
        self.install_path_file = 1

        # 'force' forces installation, even if target files are not
        # out-of-date.  'skip_build' skips running the "build" command,
222
        # handy if you know it's not necessary.  'warn_dir' (which is *not*
223 224 225
        # a user option, it's just there so the bdist_* commands can turn
        # it off) determines whether we warn about installing to a
        # directory not in sys.path.
226
        self.force = 0
227
        self.skip_build = 0
228
        self.warn_dir = 1
229

230 231 232 233 234 235 236 237 238
        # These are only here as a conduit from the 'build' command to the
        # 'install_*' commands that do the real work.  ('build_base' isn't
        # actually used anywhere, but it might be useful in future.)  They
        # are not user options, because if the user told the install
        # command where the build directory is, that wouldn't affect the
        # build command.
        self.build_base = None
        self.build_lib = None

239 240
        # Not defined yet because we don't know anything about
        # documentation yet.
241 242 243
        #self.install_man = None
        #self.install_html = None
        #self.install_info = None
244

245
        self.record = None
246

247 248 249 250 251 252 253

    # -- Option finalizing methods -------------------------------------
    # (This is rather more involved than for most commands,
    # because this is where the policy for installing third-
    # party Python modules on various platforms given a wide
    # array of user input is decided.  Yes, it's quite complex!)

254
    def finalize_options (self):
255

256 257 258 259 260 261 262 263 264 265
        # This method (and its pliant slaves, like 'finalize_unix()',
        # 'finalize_other()', and 'select_scheme()') is where the default
        # installation directories for modules, extension modules, and
        # anything else we care to install from a Python module
        # distribution.  Thus, this code makes a pretty important policy
        # statement about how third-party stuff is added to a Python
        # installation!  Note that the actual work of installation is done
        # by the relatively simple 'install_*' commands; they just take
        # their orders from the installation directory options determined
        # here.
266

267 268
        # Check for errors/inconsistencies in the options; first, stuff
        # that's wrong on any platform.
269 270 271 272 273 274 275

        if ((self.prefix or self.exec_prefix or self.home) and
            (self.install_base or self.install_platbase)):
            raise DistutilsOptionError, \
                  ("must supply either prefix/exec-prefix/home or " +
                   "install-base/install-platbase -- not both")

276 277 278 279
        if self.home and (self.prefix or self.exec_prefix):
            raise DistutilsOptionError, \
                  "must supply either home or prefix/exec-prefix -- not both"

Christian Heimes's avatar
Christian Heimes committed
280 281 282 283 284
        if self.user and (self.prefix or self.exec_prefix or self.home or
                self.install_base or self.install_platbase):
            raise DistutilsOptionError("can't combine user with with prefix/"
                                       "exec_prefix/home or install_(plat)base")

285
        # Next, stuff that's wrong (or dubious) only on certain platforms.
286
        if os.name != "posix":
287
            if self.exec_prefix:
288
                self.warn("exec-prefix option ignored on this platform")
289 290 291 292 293 294 295 296 297
                self.exec_prefix = None

        # Now the interesting logic -- so interesting that we farm it out
        # to other methods.  The goal of these methods is to set the final
        # values for the install_{lib,scripts,data,...}  options, using as
        # input a heady brew of prefix, exec_prefix, home, install_base,
        # install_platbase, user-supplied versions of
        # install_{purelib,platlib,lib,scripts,data,...}, and the
        # INSTALL_SCHEME dictionary above.  Phew!
298

299
        self.dump_dirs("pre-finalize_{unix,other}")
300

301
        if os.name == 'posix':
302
            self.finalize_unix()
303
        else:
304
            self.finalize_other()
305

306
        self.dump_dirs("post-finalize_{unix,other}()")
307 308 309 310 311 312

        # Expand configuration variables, tilde, etc. in self.install_base
        # and self.install_platbase -- that way, we can use $base or
        # $platbase in the other installation directories and not worry
        # about needing recursive variable expansion (shudder).

313
        py_version = (string.split(sys.version))[0]
Greg Ward's avatar
Greg Ward committed
314
        (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
315 316 317 318 319
        self.config_vars = {'dist_name': self.distribution.get_name(),
                            'dist_version': self.distribution.get_version(),
                            'dist_fullname': self.distribution.get_fullname(),
                            'py_version': py_version,
                            'py_version_short': py_version[0:3],
Christian Heimes's avatar
Christian Heimes committed
320
                            'py_version_nodot': py_version[0] + py_version[2],
321 322 323 324
                            'sys_prefix': prefix,
                            'prefix': prefix,
                            'sys_exec_prefix': exec_prefix,
                            'exec_prefix': exec_prefix,
Christian Heimes's avatar
Christian Heimes committed
325 326
                            'userbase': self.install_userbase,
                            'usersite': self.install_usersite,
327
                           }
328
        self.expand_basedirs()
329

330
        self.dump_dirs("post-expand_basedirs()")
331 332 333 334 335 336

        # Now define config vars for the base directories so we can expand
        # everything else.
        self.config_vars['base'] = self.install_base
        self.config_vars['platbase'] = self.install_platbase

337 338 339
        if DEBUG:
            from pprint import pprint
            print "config vars:"
340
            pprint(self.config_vars)
341

342 343
        # Expand "~" and configuration variables in the installation
        # directories.
344
        self.expand_dirs()
345

346
        self.dump_dirs("post-expand_dirs()")
347

Christian Heimes's avatar
Christian Heimes committed
348 349 350 351
        # Create directories in the home dir:
        if self.user:
            self.create_home_path()

352 353 354 355 356 357 358 359 360
        # Pick the actual directory to install all modules to: either
        # install_purelib or install_platlib, depending on whether this
        # module distribution is pure or not.  Of course, if the user
        # already specified install_lib, use their selection.
        if self.install_lib is None:
            if self.distribution.ext_modules: # has extensions: non-pure
                self.install_lib = self.install_platlib
            else:
                self.install_lib = self.install_purelib
Fred Drake's avatar
Fred Drake committed
361

362 363 364 365

        # Convert directories from Unix /-separated syntax to the local
        # convention.
        self.convert_paths('lib', 'purelib', 'platlib',
Christian Heimes's avatar
Christian Heimes committed
366 367
                           'scripts', 'data', 'headers',
                           'userbase', 'usersite')
368

369 370 371 372
        # Well, we're not actually fully completely finalized yet: we still
        # have to deal with 'extra_path', which is the hack for allowing
        # non-packagized module distributions (hello, Numerical Python!) to
        # get their own directories.
373
        self.handle_extra_path()
374
        self.install_libbase = self.install_lib # needed for .pth file
375
        self.install_lib = os.path.join(self.install_lib, self.extra_dirs)
376

377 378 379
        # If a new root directory was supplied, make all the installation
        # dirs relative to it.
        if self.root is not None:
380 381
            self.change_roots('libbase', 'lib', 'purelib', 'platlib',
                              'scripts', 'data', 'headers')
382

383
        self.dump_dirs("after prepending root")
384

385
        # Find out the build directories, ie. where to install from.
386 387 388
        self.set_undefined_options('build',
                                   ('build_base', 'build_base'),
                                   ('build_lib', 'build_lib'))
389 390 391

        # Punt on doc directories for now -- after all, we're punting on
        # documentation completely!
392

393 394 395
    # finalize_options ()


396
    def dump_dirs (self, msg):
397 398 399 400 401 402 403
        if DEBUG:
            from distutils.fancy_getopt import longopt_xlate
            print msg + ":"
            for opt in self.user_options:
                opt_name = opt[0]
                if opt_name[-1] == "=":
                    opt_name = opt_name[0:-1]
404
                if opt_name in self.negative_opt:
405 406 407 408 409 410
                    opt_name = string.translate(self.negative_opt[opt_name],
                                                longopt_xlate)
                    val = not getattr(self, opt_name)
                else:
                    opt_name = string.translate(opt_name, longopt_xlate)
                    val = getattr(self, opt_name)
411
                print "  %s: %s" % (opt_name, val)
412 413


414
    def finalize_unix (self):
Fred Drake's avatar
Fred Drake committed
415

416 417 418 419
        if self.install_base is not None or self.install_platbase is not None:
            if ((self.install_lib is None and
                 self.install_purelib is None and
                 self.install_platlib is None) or
420
                self.install_headers is None or
421 422 423
                self.install_scripts is None or
                self.install_data is None):
                raise DistutilsOptionError, \
424 425
                      ("install-base or install-platbase supplied, but "
                      "installation scheme is incomplete")
426 427
            return

Christian Heimes's avatar
Christian Heimes committed
428 429 430 431 432 433 434
        if self.user:
            if self.install_userbase is None:
                raise DistutilsPlatformError(
                    "User base directory is not specified")
            self.install_base = self.install_platbase = self.install_userbase
            self.select_scheme("unix_user")
        elif self.home is not None:
435
            self.install_base = self.install_platbase = self.home
436
            self.select_scheme("unix_home")
437
        else:
438 439 440 441 442
            if self.prefix is None:
                if self.exec_prefix is not None:
                    raise DistutilsOptionError, \
                          "must not supply exec-prefix without prefix"

443 444
                self.prefix = os.path.normpath(sys.prefix)
                self.exec_prefix = os.path.normpath(sys.exec_prefix)
445 446 447 448 449 450 451

            else:
                if self.exec_prefix is None:
                    self.exec_prefix = self.prefix

            self.install_base = self.prefix
            self.install_platbase = self.exec_prefix
452
            self.select_scheme("unix_prefix")
453 454 455 456 457 458

    # finalize_unix ()


    def finalize_other (self):          # Windows and Mac OS for now

Christian Heimes's avatar
Christian Heimes committed
459 460 461 462 463 464 465
        if self.user:
            if self.install_userbase is None:
                raise DistutilsPlatformError(
                    "User base directory is not specified")
            self.install_base = self.install_platbase = self.install_userbase
            self.select_scheme(os.name + "_user")
        elif self.home is not None:
466 467 468 469 470
            self.install_base = self.install_platbase = self.home
            self.select_scheme("unix_home")
        else:
            if self.prefix is None:
                self.prefix = os.path.normpath(sys.prefix)
471

472 473 474 475 476 477
            self.install_base = self.install_platbase = self.prefix
            try:
                self.select_scheme(os.name)
            except KeyError:
                raise DistutilsPlatformError, \
                      "I don't know how to install stuff on '%s'" % os.name
478

479 480 481 482 483 484
    # finalize_other ()


    def select_scheme (self, name):
        # it's the caller's problem if they supply a bad name!
        scheme = INSTALL_SCHEMES[name]
485
        for key in SCHEME_KEYS:
486 487 488
            attrname = 'install_' + key
            if getattr(self, attrname) is None:
                setattr(self, attrname, scheme[key])
489 490


491 492
    def _expand_attrs (self, attrs):
        for attr in attrs:
493
            val = getattr(self, attr)
494
            if val is not None:
Christian Heimes's avatar
Christian Heimes committed
495
                if os.name == 'posix' or os.name == 'nt':
496 497 498
                    val = os.path.expanduser(val)
                val = subst_vars(val, self.config_vars)
                setattr(self, attr, val)
499 500


501
    def expand_basedirs (self):
502 503
        self._expand_attrs(['install_base',
                            'install_platbase',
Fred Drake's avatar
Fred Drake committed
504
                            'root'])
505 506

    def expand_dirs (self):
507 508 509 510 511 512
        self._expand_attrs(['install_purelib',
                            'install_platlib',
                            'install_lib',
                            'install_headers',
                            'install_scripts',
                            'install_data',])
513 514


515 516 517 518 519 520
    def convert_paths (self, *names):
        for name in names:
            attr = "install_" + name
            setattr(self, attr, convert_path(getattr(self, attr)))


521
    def handle_extra_path (self):
522

523 524 525 526
        if self.extra_path is None:
            self.extra_path = self.distribution.extra_path

        if self.extra_path is not None:
527 528
            if type(self.extra_path) is StringType:
                self.extra_path = string.split(self.extra_path, ',')
529

530
            if len(self.extra_path) == 1:
531
                path_file = extra_dirs = self.extra_path[0]
532
            elif len(self.extra_path) == 2:
533
                (path_file, extra_dirs) = self.extra_path
534
            else:
535
                raise DistutilsOptionError, \
536 537
                      ("'extra_path' option must be a list, tuple, or "
                      "comma-separated string with 1 or 2 elements")
538

539 540
            # convert to local form in case Unix notation used (as it
            # should be in setup scripts)
541
            extra_dirs = convert_path(extra_dirs)
542

543 544 545 546
        else:
            path_file = None
            extra_dirs = ''

547 548
        # XXX should we warn if path_file and not extra_dirs? (in which
        # case the path file would be harmless but pointless)
549 550 551
        self.path_file = path_file
        self.extra_dirs = extra_dirs

552
    # handle_extra_path ()
553 554


555 556 557 558 559
    def change_roots (self, *names):
        for name in names:
            attr = "install_" + name
            setattr(self, attr, change_root(self.root, getattr(self, attr)))

Christian Heimes's avatar
Christian Heimes committed
560 561 562 563 564 565 566 567 568 569
    def create_home_path(self):
        """Create directories under ~
        """
        if not self.user:
            return
        home = convert_path(os.path.expanduser("~"))
        for name, path in self.config_vars.iteritems():
            if path.startswith(home) and not os.path.isdir(path):
                self.debug_print("os.makedirs('%s', 0700)" % path)
                os.makedirs(path, 0700)
570

571 572
    # -- Command execution methods -------------------------------------

573 574
    def run (self):

575
        # Obviously have to build before we can install
576
        if not self.skip_build:
577
            self.run_command('build')
578 579 580 581 582 583 584 585
            # If we built for any other platform, we can't install.
            build_plat = self.distribution.get_command_obj('build').plat_name
            # check warn_dir - it is a clue that the 'install' is happening
            # internally, and not to sys.path, so we don't check the platform
            # matches what we are running.
            if self.warn_dir and build_plat != get_platform():
                raise DistutilsPlatformError("Can't install when "
                                             "cross-compiling")
586

587 588
        # Run all sub-commands (at least those that need to be run)
        for cmd_name in self.get_sub_commands():
589
            self.run_command(cmd_name)
590 591

        if self.path_file:
592
            self.create_path_file()
593

594 595 596
        # write list of installed files, if requested.
        if self.record:
            outputs = self.get_outputs()
597
            if self.root:               # strip any package prefix
598
                root_len = len(self.root)
599
                for counter in xrange(len(outputs)):
600 601
                    outputs[counter] = outputs[counter][root_len:]
            self.execute(write_file,
602 603 604
                         (self.record, outputs),
                         "writing list of installed files to '%s'" %
                         self.record)
605

606
        sys_path = map(os.path.normpath, sys.path)
Greg Ward's avatar
Greg Ward committed
607
        sys_path = map(os.path.normcase, sys_path)
608
        install_lib = os.path.normcase(os.path.normpath(self.install_lib))
609 610
        if (self.warn_dir and
            not (self.path_file and self.install_path_file) and
611
            install_lib not in sys_path):
612
            log.debug(("modules installed to '%s', which is not in "
613
                       "Python's module search path (sys.path) -- "
614 615
                       "you'll have to change the search path yourself"),
                       self.install_lib)
616

617 618
    # run ()

619
    def create_path_file (self):
620 621
        filename = os.path.join(self.install_libbase,
                                self.path_file + ".pth")
622
        if self.install_path_file:
623 624 625
            self.execute(write_file,
                         (filename, [self.extra_dirs]),
                         "creating %s" % filename)
626 627
        else:
            self.warn("path file '%s' not created" % filename)
628

629

630
    # -- Reporting methods ---------------------------------------------
631

632
    def get_outputs (self):
633
        # Assemble the outputs of all the sub-commands.
634
        outputs = []
635
        for cmd_name in self.get_sub_commands():
636
            cmd = self.get_finalized_command(cmd_name)
637 638 639 640 641
            # Add the contents of cmd.get_outputs(), ensuring
            # that outputs doesn't contain duplicate entries
            for filename in cmd.get_outputs():
                if filename not in outputs:
                    outputs.append(filename)
642

643 644 645
        if self.path_file and self.install_path_file:
            outputs.append(os.path.join(self.install_libbase,
                                        self.path_file + ".pth"))
Fred Drake's avatar
Fred Drake committed
646

647 648
        return outputs

649 650 651
    def get_inputs (self):
        # XXX gee, this looks familiar ;-(
        inputs = []
652
        for cmd_name in self.get_sub_commands():
653 654
            cmd = self.get_finalized_command(cmd_name)
            inputs.extend(cmd.get_inputs())
655 656 657 658

        return inputs


659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675
    # -- Predicates for sub-command list -------------------------------

    def has_lib (self):
        """Return true if the current distribution has any Python
        modules to install."""
        return (self.distribution.has_pure_modules() or
                self.distribution.has_ext_modules())

    def has_headers (self):
        return self.distribution.has_headers()

    def has_scripts (self):
        return self.distribution.has_scripts()

    def has_data (self):
        return self.distribution.has_data_files()

676

677 678 679 680 681 682
    # 'sub_commands': a list of commands this command might have to run to
    # get its work done.  See cmd.py for more info.
    sub_commands = [('install_lib',     has_lib),
                    ('install_headers', has_headers),
                    ('install_scripts', has_scripts),
                    ('install_data',    has_data),
683
                    ('install_egg_info', lambda self:True),
684 685
                   ]

686
# class install