ยปCore Development>Code coverage>Lib/distutils/command/install.py

Python code coverage for Lib/distutils/command/install.py

#countcontent
1n/a"""distutils.command.install
2n/a
3n/aImplements the Distutils 'install' command."""
4n/a
5n/aimport sys
6n/aimport os
7n/a
8n/afrom distutils import log
9n/afrom distutils.core import Command
10n/afrom distutils.debug import DEBUG
11n/afrom distutils.sysconfig import get_config_vars
12n/afrom distutils.errors import DistutilsPlatformError
13n/afrom distutils.file_util import write_file
14n/afrom distutils.util import convert_path, subst_vars, change_root
15n/afrom distutils.util import get_platform
16n/afrom distutils.errors import DistutilsOptionError
17n/a
18n/afrom site import USER_BASE
19n/afrom site import USER_SITE
20n/aHAS_USER_SITE = True
21n/a
22n/aWINDOWS_SCHEME = {
23n/a 'purelib': '$base/Lib/site-packages',
24n/a 'platlib': '$base/Lib/site-packages',
25n/a 'headers': '$base/Include/$dist_name',
26n/a 'scripts': '$base/Scripts',
27n/a 'data' : '$base',
28n/a}
29n/a
30n/aINSTALL_SCHEMES = {
31n/a 'unix_prefix': {
32n/a 'purelib': '$base/lib/python$py_version_short/site-packages',
33n/a 'platlib': '$platbase/lib/python$py_version_short/site-packages',
34n/a 'headers': '$base/include/python$py_version_short$abiflags/$dist_name',
35n/a 'scripts': '$base/bin',
36n/a 'data' : '$base',
37n/a },
38n/a 'unix_home': {
39n/a 'purelib': '$base/lib/python',
40n/a 'platlib': '$base/lib/python',
41n/a 'headers': '$base/include/python/$dist_name',
42n/a 'scripts': '$base/bin',
43n/a 'data' : '$base',
44n/a },
45n/a 'nt': WINDOWS_SCHEME,
46n/a }
47n/a
48n/a# user site schemes
49n/aif HAS_USER_SITE:
50n/a INSTALL_SCHEMES['nt_user'] = {
51n/a 'purelib': '$usersite',
52n/a 'platlib': '$usersite',
53n/a 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name',
54n/a 'scripts': '$userbase/Python$py_version_nodot/Scripts',
55n/a 'data' : '$userbase',
56n/a }
57n/a
58n/a INSTALL_SCHEMES['unix_user'] = {
59n/a 'purelib': '$usersite',
60n/a 'platlib': '$usersite',
61n/a 'headers':
62n/a '$userbase/include/python$py_version_short$abiflags/$dist_name',
63n/a 'scripts': '$userbase/bin',
64n/a 'data' : '$userbase',
65n/a }
66n/a
67n/a# The keys to an installation scheme; if any new types of files are to be
68n/a# installed, be sure to add an entry to every installation scheme above,
69n/a# and to SCHEME_KEYS here.
70n/aSCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data')
71n/a
72n/a
73n/aclass install(Command):
74n/a
75n/a description = "install everything from build directory"
76n/a
77n/a user_options = [
78n/a # Select installation scheme and set base director(y|ies)
79n/a ('prefix=', None,
80n/a "installation prefix"),
81n/a ('exec-prefix=', None,
82n/a "(Unix only) prefix for platform-specific files"),
83n/a ('home=', None,
84n/a "(Unix only) home directory to install under"),
85n/a
86n/a # Or, just set the base director(y|ies)
87n/a ('install-base=', None,
88n/a "base installation directory (instead of --prefix or --home)"),
89n/a ('install-platbase=', None,
90n/a "base installation directory for platform-specific files " +
91n/a "(instead of --exec-prefix or --home)"),
92n/a ('root=', None,
93n/a "install everything relative to this alternate root directory"),
94n/a
95n/a # Or, explicitly set the installation scheme
96n/a ('install-purelib=', None,
97n/a "installation directory for pure Python module distributions"),
98n/a ('install-platlib=', None,
99n/a "installation directory for non-pure module distributions"),
100n/a ('install-lib=', None,
101n/a "installation directory for all module distributions " +
102n/a "(overrides --install-purelib and --install-platlib)"),
103n/a
104n/a ('install-headers=', None,
105n/a "installation directory for C/C++ headers"),
106n/a ('install-scripts=', None,
107n/a "installation directory for Python scripts"),
108n/a ('install-data=', None,
109n/a "installation directory for data files"),
110n/a
111n/a # Byte-compilation options -- see install_lib.py for details, as
112n/a # these are duplicated from there (but only install_lib does
113n/a # anything with them).
114n/a ('compile', 'c', "compile .py to .pyc [default]"),
115n/a ('no-compile', None, "don't compile .py files"),
116n/a ('optimize=', 'O',
117n/a "also compile with optimization: -O1 for \"python -O\", "
118n/a "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"),
119n/a
120n/a # Miscellaneous control options
121n/a ('force', 'f',
122n/a "force installation (overwrite any existing files)"),
123n/a ('skip-build', None,
124n/a "skip rebuilding everything (for testing/debugging)"),
125n/a
126n/a # Where to install documentation (eventually!)
127n/a #('doc-format=', None, "format of documentation to generate"),
128n/a #('install-man=', None, "directory for Unix man pages"),
129n/a #('install-html=', None, "directory for HTML documentation"),
130n/a #('install-info=', None, "directory for GNU info files"),
131n/a
132n/a ('record=', None,
133n/a "filename in which to record list of installed files"),
134n/a ]
135n/a
136n/a boolean_options = ['compile', 'force', 'skip-build']
137n/a
138n/a if HAS_USER_SITE:
139n/a user_options.append(('user', None,
140n/a "install in user site-package '%s'" % USER_SITE))
141n/a boolean_options.append('user')
142n/a
143n/a negative_opt = {'no-compile' : 'compile'}
144n/a
145n/a
146n/a def initialize_options(self):
147n/a """Initializes options."""
148n/a # High-level options: these select both an installation base
149n/a # and scheme.
150n/a self.prefix = None
151n/a self.exec_prefix = None
152n/a self.home = None
153n/a self.user = 0
154n/a
155n/a # These select only the installation base; it's up to the user to
156n/a # specify the installation scheme (currently, that means supplying
157n/a # the --install-{platlib,purelib,scripts,data} options).
158n/a self.install_base = None
159n/a self.install_platbase = None
160n/a self.root = None
161n/a
162n/a # These options are the actual installation directories; if not
163n/a # supplied by the user, they are filled in using the installation
164n/a # scheme implied by prefix/exec-prefix/home and the contents of
165n/a # that installation scheme.
166n/a self.install_purelib = None # for pure module distributions
167n/a self.install_platlib = None # non-pure (dists w/ extensions)
168n/a self.install_headers = None # for C/C++ headers
169n/a self.install_lib = None # set to either purelib or platlib
170n/a self.install_scripts = None
171n/a self.install_data = None
172n/a self.install_userbase = USER_BASE
173n/a self.install_usersite = USER_SITE
174n/a
175n/a self.compile = None
176n/a self.optimize = None
177n/a
178n/a # Deprecated
179n/a # These two are for putting non-packagized distributions into their
180n/a # own directory and creating a .pth file if it makes sense.
181n/a # 'extra_path' comes from the setup file; 'install_path_file' can
182n/a # be turned off if it makes no sense to install a .pth file. (But
183n/a # better to install it uselessly than to guess wrong and not
184n/a # install it when it's necessary and would be used!) Currently,
185n/a # 'install_path_file' is always true unless some outsider meddles
186n/a # with it.
187n/a self.extra_path = None
188n/a self.install_path_file = 1
189n/a
190n/a # 'force' forces installation, even if target files are not
191n/a # out-of-date. 'skip_build' skips running the "build" command,
192n/a # handy if you know it's not necessary. 'warn_dir' (which is *not*
193n/a # a user option, it's just there so the bdist_* commands can turn
194n/a # it off) determines whether we warn about installing to a
195n/a # directory not in sys.path.
196n/a self.force = 0
197n/a self.skip_build = 0
198n/a self.warn_dir = 1
199n/a
200n/a # These are only here as a conduit from the 'build' command to the
201n/a # 'install_*' commands that do the real work. ('build_base' isn't
202n/a # actually used anywhere, but it might be useful in future.) They
203n/a # are not user options, because if the user told the install
204n/a # command where the build directory is, that wouldn't affect the
205n/a # build command.
206n/a self.build_base = None
207n/a self.build_lib = None
208n/a
209n/a # Not defined yet because we don't know anything about
210n/a # documentation yet.
211n/a #self.install_man = None
212n/a #self.install_html = None
213n/a #self.install_info = None
214n/a
215n/a self.record = None
216n/a
217n/a
218n/a # -- Option finalizing methods -------------------------------------
219n/a # (This is rather more involved than for most commands,
220n/a # because this is where the policy for installing third-
221n/a # party Python modules on various platforms given a wide
222n/a # array of user input is decided. Yes, it's quite complex!)
223n/a
224n/a def finalize_options(self):
225n/a """Finalizes options."""
226n/a # This method (and its pliant slaves, like 'finalize_unix()',
227n/a # 'finalize_other()', and 'select_scheme()') is where the default
228n/a # installation directories for modules, extension modules, and
229n/a # anything else we care to install from a Python module
230n/a # distribution. Thus, this code makes a pretty important policy
231n/a # statement about how third-party stuff is added to a Python
232n/a # installation! Note that the actual work of installation is done
233n/a # by the relatively simple 'install_*' commands; they just take
234n/a # their orders from the installation directory options determined
235n/a # here.
236n/a
237n/a # Check for errors/inconsistencies in the options; first, stuff
238n/a # that's wrong on any platform.
239n/a
240n/a if ((self.prefix or self.exec_prefix or self.home) and
241n/a (self.install_base or self.install_platbase)):
242n/a raise DistutilsOptionError(
243n/a "must supply either prefix/exec-prefix/home or " +
244n/a "install-base/install-platbase -- not both")
245n/a
246n/a if self.home and (self.prefix or self.exec_prefix):
247n/a raise DistutilsOptionError(
248n/a "must supply either home or prefix/exec-prefix -- not both")
249n/a
250n/a if self.user and (self.prefix or self.exec_prefix or self.home or
251n/a self.install_base or self.install_platbase):
252n/a raise DistutilsOptionError("can't combine user with prefix, "
253n/a "exec_prefix/home, or install_(plat)base")
254n/a
255n/a # Next, stuff that's wrong (or dubious) only on certain platforms.
256n/a if os.name != "posix":
257n/a if self.exec_prefix:
258n/a self.warn("exec-prefix option ignored on this platform")
259n/a self.exec_prefix = None
260n/a
261n/a # Now the interesting logic -- so interesting that we farm it out
262n/a # to other methods. The goal of these methods is to set the final
263n/a # values for the install_{lib,scripts,data,...} options, using as
264n/a # input a heady brew of prefix, exec_prefix, home, install_base,
265n/a # install_platbase, user-supplied versions of
266n/a # install_{purelib,platlib,lib,scripts,data,...}, and the
267n/a # INSTALL_SCHEME dictionary above. Phew!
268n/a
269n/a self.dump_dirs("pre-finalize_{unix,other}")
270n/a
271n/a if os.name == 'posix':
272n/a self.finalize_unix()
273n/a else:
274n/a self.finalize_other()
275n/a
276n/a self.dump_dirs("post-finalize_{unix,other}()")
277n/a
278n/a # Expand configuration variables, tilde, etc. in self.install_base
279n/a # and self.install_platbase -- that way, we can use $base or
280n/a # $platbase in the other installation directories and not worry
281n/a # about needing recursive variable expansion (shudder).
282n/a
283n/a py_version = sys.version.split()[0]
284n/a (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
285n/a try:
286n/a abiflags = sys.abiflags
287n/a except AttributeError:
288n/a # sys.abiflags may not be defined on all platforms.
289n/a abiflags = ''
290n/a self.config_vars = {'dist_name': self.distribution.get_name(),
291n/a 'dist_version': self.distribution.get_version(),
292n/a 'dist_fullname': self.distribution.get_fullname(),
293n/a 'py_version': py_version,
294n/a 'py_version_short': '%d.%d' % sys.version_info[:2],
295n/a 'py_version_nodot': '%d%d' % sys.version_info[:2],
296n/a 'sys_prefix': prefix,
297n/a 'prefix': prefix,
298n/a 'sys_exec_prefix': exec_prefix,
299n/a 'exec_prefix': exec_prefix,
300n/a 'abiflags': abiflags,
301n/a }
302n/a
303n/a if HAS_USER_SITE:
304n/a self.config_vars['userbase'] = self.install_userbase
305n/a self.config_vars['usersite'] = self.install_usersite
306n/a
307n/a self.expand_basedirs()
308n/a
309n/a self.dump_dirs("post-expand_basedirs()")
310n/a
311n/a # Now define config vars for the base directories so we can expand
312n/a # everything else.
313n/a self.config_vars['base'] = self.install_base
314n/a self.config_vars['platbase'] = self.install_platbase
315n/a
316n/a if DEBUG:
317n/a from pprint import pprint
318n/a print("config vars:")
319n/a pprint(self.config_vars)
320n/a
321n/a # Expand "~" and configuration variables in the installation
322n/a # directories.
323n/a self.expand_dirs()
324n/a
325n/a self.dump_dirs("post-expand_dirs()")
326n/a
327n/a # Create directories in the home dir:
328n/a if self.user:
329n/a self.create_home_path()
330n/a
331n/a # Pick the actual directory to install all modules to: either
332n/a # install_purelib or install_platlib, depending on whether this
333n/a # module distribution is pure or not. Of course, if the user
334n/a # already specified install_lib, use their selection.
335n/a if self.install_lib is None:
336n/a if self.distribution.ext_modules: # has extensions: non-pure
337n/a self.install_lib = self.install_platlib
338n/a else:
339n/a self.install_lib = self.install_purelib
340n/a
341n/a
342n/a # Convert directories from Unix /-separated syntax to the local
343n/a # convention.
344n/a self.convert_paths('lib', 'purelib', 'platlib',
345n/a 'scripts', 'data', 'headers',
346n/a 'userbase', 'usersite')
347n/a
348n/a # Deprecated
349n/a # Well, we're not actually fully completely finalized yet: we still
350n/a # have to deal with 'extra_path', which is the hack for allowing
351n/a # non-packagized module distributions (hello, Numerical Python!) to
352n/a # get their own directories.
353n/a self.handle_extra_path()
354n/a self.install_libbase = self.install_lib # needed for .pth file
355n/a self.install_lib = os.path.join(self.install_lib, self.extra_dirs)
356n/a
357n/a # If a new root directory was supplied, make all the installation
358n/a # dirs relative to it.
359n/a if self.root is not None:
360n/a self.change_roots('libbase', 'lib', 'purelib', 'platlib',
361n/a 'scripts', 'data', 'headers')
362n/a
363n/a self.dump_dirs("after prepending root")
364n/a
365n/a # Find out the build directories, ie. where to install from.
366n/a self.set_undefined_options('build',
367n/a ('build_base', 'build_base'),
368n/a ('build_lib', 'build_lib'))
369n/a
370n/a # Punt on doc directories for now -- after all, we're punting on
371n/a # documentation completely!
372n/a
373n/a def dump_dirs(self, msg):
374n/a """Dumps the list of user options."""
375n/a if not DEBUG:
376n/a return
377n/a from distutils.fancy_getopt import longopt_xlate
378n/a log.debug(msg + ":")
379n/a for opt in self.user_options:
380n/a opt_name = opt[0]
381n/a if opt_name[-1] == "=":
382n/a opt_name = opt_name[0:-1]
383n/a if opt_name in self.negative_opt:
384n/a opt_name = self.negative_opt[opt_name]
385n/a opt_name = opt_name.translate(longopt_xlate)
386n/a val = not getattr(self, opt_name)
387n/a else:
388n/a opt_name = opt_name.translate(longopt_xlate)
389n/a val = getattr(self, opt_name)
390n/a log.debug(" %s: %s", opt_name, val)
391n/a
392n/a def finalize_unix(self):
393n/a """Finalizes options for posix platforms."""
394n/a if self.install_base is not None or self.install_platbase is not None:
395n/a if ((self.install_lib is None and
396n/a self.install_purelib is None and
397n/a self.install_platlib is None) or
398n/a self.install_headers is None or
399n/a self.install_scripts is None or
400n/a self.install_data is None):
401n/a raise DistutilsOptionError(
402n/a "install-base or install-platbase supplied, but "
403n/a "installation scheme is incomplete")
404n/a return
405n/a
406n/a if self.user:
407n/a if self.install_userbase is None:
408n/a raise DistutilsPlatformError(
409n/a "User base directory is not specified")
410n/a self.install_base = self.install_platbase = self.install_userbase
411n/a self.select_scheme("unix_user")
412n/a elif self.home is not None:
413n/a self.install_base = self.install_platbase = self.home
414n/a self.select_scheme("unix_home")
415n/a else:
416n/a if self.prefix is None:
417n/a if self.exec_prefix is not None:
418n/a raise DistutilsOptionError(
419n/a "must not supply exec-prefix without prefix")
420n/a
421n/a self.prefix = os.path.normpath(sys.prefix)
422n/a self.exec_prefix = os.path.normpath(sys.exec_prefix)
423n/a
424n/a else:
425n/a if self.exec_prefix is None:
426n/a self.exec_prefix = self.prefix
427n/a
428n/a self.install_base = self.prefix
429n/a self.install_platbase = self.exec_prefix
430n/a self.select_scheme("unix_prefix")
431n/a
432n/a def finalize_other(self):
433n/a """Finalizes options for non-posix platforms"""
434n/a if self.user:
435n/a if self.install_userbase is None:
436n/a raise DistutilsPlatformError(
437n/a "User base directory is not specified")
438n/a self.install_base = self.install_platbase = self.install_userbase
439n/a self.select_scheme(os.name + "_user")
440n/a elif self.home is not None:
441n/a self.install_base = self.install_platbase = self.home
442n/a self.select_scheme("unix_home")
443n/a else:
444n/a if self.prefix is None:
445n/a self.prefix = os.path.normpath(sys.prefix)
446n/a
447n/a self.install_base = self.install_platbase = self.prefix
448n/a try:
449n/a self.select_scheme(os.name)
450n/a except KeyError:
451n/a raise DistutilsPlatformError(
452n/a "I don't know how to install stuff on '%s'" % os.name)
453n/a
454n/a def select_scheme(self, name):
455n/a """Sets the install directories by applying the install schemes."""
456n/a # it's the caller's problem if they supply a bad name!
457n/a scheme = INSTALL_SCHEMES[name]
458n/a for key in SCHEME_KEYS:
459n/a attrname = 'install_' + key
460n/a if getattr(self, attrname) is None:
461n/a setattr(self, attrname, scheme[key])
462n/a
463n/a def _expand_attrs(self, attrs):
464n/a for attr in attrs:
465n/a val = getattr(self, attr)
466n/a if val is not None:
467n/a if os.name == 'posix' or os.name == 'nt':
468n/a val = os.path.expanduser(val)
469n/a val = subst_vars(val, self.config_vars)
470n/a setattr(self, attr, val)
471n/a
472n/a def expand_basedirs(self):
473n/a """Calls `os.path.expanduser` on install_base, install_platbase and
474n/a root."""
475n/a self._expand_attrs(['install_base', 'install_platbase', 'root'])
476n/a
477n/a def expand_dirs(self):
478n/a """Calls `os.path.expanduser` on install dirs."""
479n/a self._expand_attrs(['install_purelib', 'install_platlib',
480n/a 'install_lib', 'install_headers',
481n/a 'install_scripts', 'install_data',])
482n/a
483n/a def convert_paths(self, *names):
484n/a """Call `convert_path` over `names`."""
485n/a for name in names:
486n/a attr = "install_" + name
487n/a setattr(self, attr, convert_path(getattr(self, attr)))
488n/a
489n/a def handle_extra_path(self):
490n/a """Set `path_file` and `extra_dirs` using `extra_path`."""
491n/a if self.extra_path is None:
492n/a self.extra_path = self.distribution.extra_path
493n/a
494n/a if self.extra_path is not None:
495n/a log.warn(
496n/a "Distribution option extra_path is deprecated. "
497n/a "See issue27919 for details."
498n/a )
499n/a if isinstance(self.extra_path, str):
500n/a self.extra_path = self.extra_path.split(',')
501n/a
502n/a if len(self.extra_path) == 1:
503n/a path_file = extra_dirs = self.extra_path[0]
504n/a elif len(self.extra_path) == 2:
505n/a path_file, extra_dirs = self.extra_path
506n/a else:
507n/a raise DistutilsOptionError(
508n/a "'extra_path' option must be a list, tuple, or "
509n/a "comma-separated string with 1 or 2 elements")
510n/a
511n/a # convert to local form in case Unix notation used (as it
512n/a # should be in setup scripts)
513n/a extra_dirs = convert_path(extra_dirs)
514n/a else:
515n/a path_file = None
516n/a extra_dirs = ''
517n/a
518n/a # XXX should we warn if path_file and not extra_dirs? (in which
519n/a # case the path file would be harmless but pointless)
520n/a self.path_file = path_file
521n/a self.extra_dirs = extra_dirs
522n/a
523n/a def change_roots(self, *names):
524n/a """Change the install directories pointed by name using root."""
525n/a for name in names:
526n/a attr = "install_" + name
527n/a setattr(self, attr, change_root(self.root, getattr(self, attr)))
528n/a
529n/a def create_home_path(self):
530n/a """Create directories under ~."""
531n/a if not self.user:
532n/a return
533n/a home = convert_path(os.path.expanduser("~"))
534n/a for name, path in self.config_vars.items():
535n/a if path.startswith(home) and not os.path.isdir(path):
536n/a self.debug_print("os.makedirs('%s', 0o700)" % path)
537n/a os.makedirs(path, 0o700)
538n/a
539n/a # -- Command execution methods -------------------------------------
540n/a
541n/a def run(self):
542n/a """Runs the command."""
543n/a # Obviously have to build before we can install
544n/a if not self.skip_build:
545n/a self.run_command('build')
546n/a # If we built for any other platform, we can't install.
547n/a build_plat = self.distribution.get_command_obj('build').plat_name
548n/a # check warn_dir - it is a clue that the 'install' is happening
549n/a # internally, and not to sys.path, so we don't check the platform
550n/a # matches what we are running.
551n/a if self.warn_dir and build_plat != get_platform():
552n/a raise DistutilsPlatformError("Can't install when "
553n/a "cross-compiling")
554n/a
555n/a # Run all sub-commands (at least those that need to be run)
556n/a for cmd_name in self.get_sub_commands():
557n/a self.run_command(cmd_name)
558n/a
559n/a if self.path_file:
560n/a self.create_path_file()
561n/a
562n/a # write list of installed files, if requested.
563n/a if self.record:
564n/a outputs = self.get_outputs()
565n/a if self.root: # strip any package prefix
566n/a root_len = len(self.root)
567n/a for counter in range(len(outputs)):
568n/a outputs[counter] = outputs[counter][root_len:]
569n/a self.execute(write_file,
570n/a (self.record, outputs),
571n/a "writing list of installed files to '%s'" %
572n/a self.record)
573n/a
574n/a sys_path = map(os.path.normpath, sys.path)
575n/a sys_path = map(os.path.normcase, sys_path)
576n/a install_lib = os.path.normcase(os.path.normpath(self.install_lib))
577n/a if (self.warn_dir and
578n/a not (self.path_file and self.install_path_file) and
579n/a install_lib not in sys_path):
580n/a log.debug(("modules installed to '%s', which is not in "
581n/a "Python's module search path (sys.path) -- "
582n/a "you'll have to change the search path yourself"),
583n/a self.install_lib)
584n/a
585n/a def create_path_file(self):
586n/a """Creates the .pth file"""
587n/a filename = os.path.join(self.install_libbase,
588n/a self.path_file + ".pth")
589n/a if self.install_path_file:
590n/a self.execute(write_file,
591n/a (filename, [self.extra_dirs]),
592n/a "creating %s" % filename)
593n/a else:
594n/a self.warn("path file '%s' not created" % filename)
595n/a
596n/a
597n/a # -- Reporting methods ---------------------------------------------
598n/a
599n/a def get_outputs(self):
600n/a """Assembles the outputs of all the sub-commands."""
601n/a outputs = []
602n/a for cmd_name in self.get_sub_commands():
603n/a cmd = self.get_finalized_command(cmd_name)
604n/a # Add the contents of cmd.get_outputs(), ensuring
605n/a # that outputs doesn't contain duplicate entries
606n/a for filename in cmd.get_outputs():
607n/a if filename not in outputs:
608n/a outputs.append(filename)
609n/a
610n/a if self.path_file and self.install_path_file:
611n/a outputs.append(os.path.join(self.install_libbase,
612n/a self.path_file + ".pth"))
613n/a
614n/a return outputs
615n/a
616n/a def get_inputs(self):
617n/a """Returns the inputs of all the sub-commands"""
618n/a # XXX gee, this looks familiar ;-(
619n/a inputs = []
620n/a for cmd_name in self.get_sub_commands():
621n/a cmd = self.get_finalized_command(cmd_name)
622n/a inputs.extend(cmd.get_inputs())
623n/a
624n/a return inputs
625n/a
626n/a # -- Predicates for sub-command list -------------------------------
627n/a
628n/a def has_lib(self):
629n/a """Returns true if the current distribution has any Python
630n/a modules to install."""
631n/a return (self.distribution.has_pure_modules() or
632n/a self.distribution.has_ext_modules())
633n/a
634n/a def has_headers(self):
635n/a """Returns true if the current distribution has any headers to
636n/a install."""
637n/a return self.distribution.has_headers()
638n/a
639n/a def has_scripts(self):
640n/a """Returns true if the current distribution has any scripts to.
641n/a install."""
642n/a return self.distribution.has_scripts()
643n/a
644n/a def has_data(self):
645n/a """Returns true if the current distribution has any data to.
646n/a install."""
647n/a return self.distribution.has_data_files()
648n/a
649n/a # 'sub_commands': a list of commands this command might have to run to
650n/a # get its work done. See cmd.py for more info.
651n/a sub_commands = [('install_lib', has_lib),
652n/a ('install_headers', has_headers),
653n/a ('install_scripts', has_scripts),
654n/a ('install_data', has_data),
655n/a ('install_egg_info', lambda self:True),
656n/a ]