logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

install.py (28242B)


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