install.py 26 KB

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