1
0

install.py 27 KB

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