summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/command/install_lib.py
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-03-29 02:17:42 (GMT)
committerGreg Ward <gward@python.net>2000-03-29 02:17:42 (GMT)
commite5dfba5e0fc3f535b58b09ca6ec489562586ceb8 (patch)
treeffa6bf0782b4c0573a98c24a70b195ab60c612c7 /Lib/distutils/command/install_lib.py
parentee94c57fe960b5a986721fdb813caae1dfb2144e (diff)
downloadcpython-e5dfba5e0fc3f535b58b09ca6ec489562586ceb8.zip
cpython-e5dfba5e0fc3f535b58b09ca6ec489562586ceb8.tar.gz
cpython-e5dfba5e0fc3f535b58b09ca6ec489562586ceb8.tar.bz2
Be sure to run both 'build_py' and 'build_ext', now that this command
is responsible for installing all Python modules (pure and extensions). Added 'get_outputs()' in preparation for the 'bdist' command, and '_mutate_outputs()' to support 'get_outputs()'.
Diffstat (limited to 'Lib/distutils/command/install_lib.py')
-rw-r--r--Lib/distutils/command/install_lib.py52
1 files changed, 47 insertions, 5 deletions
diff --git a/Lib/distutils/command/install_lib.py b/Lib/distutils/command/install_lib.py
index eaaa1c7..7e1f2e2 100644
--- a/Lib/distutils/command/install_lib.py
+++ b/Lib/distutils/command/install_lib.py
@@ -2,7 +2,7 @@
__revision__ = "$Id$"
-import sys, string
+import sys, os, string
from distutils.core import Command
from distutils.util import copy_tree
@@ -39,14 +39,17 @@ class install_lib (Command):
def run (self):
- # Make sure we have "built" all pure Python modules first
- self.run_peer ('build_py')
+ # Make sure we have built everything we need first
+ if self.distribution.has_pure_modules():
+ self.run_peer ('build_py')
+ if self.distribution.has_ext_modules():
+ self.run_peer ('build_ext')
# Install everything: simply dump the entire contents of the build
# directory to the installation directory (that's the beauty of
# having a build directory!)
outfiles = self.copy_tree (self.build_dir, self.install_dir)
-
+
# (Optionally) compile .py to .pyc
# XXX hey! we can't control whether we optimize or not; that's up
# to the invocation of the current Python interpreter (at least
@@ -73,4 +76,43 @@ class install_lib (Command):
# run ()
-# class InstallPy
+
+ def _mutate_outputs (self, has_any, build_cmd, cmd_option, output_dir):
+
+ if not has_any:
+ return []
+
+ build_cmd = self.find_peer (build_cmd)
+ build_files = build_cmd.get_outputs()
+ build_dir = build_cmd.get_option (cmd_option)
+
+ prefix_len = len (build_dir) + len (os.sep)
+ outputs = []
+ for file in build_files:
+ outputs.append (os.path.join (output_dir, file[prefix_len:]))
+
+ return outputs
+
+ # _mutate_outputs ()
+
+ def get_outputs (self):
+ """Return the list of files that would be installed if this command
+ were actually run. Not affected by the "dry-run" flag or whether
+ modules have actually been built yet."""
+
+ pure_outputs = \
+ self._mutate_outputs (self.distribution.has_pure_modules(),
+ 'build_py', 'build_lib',
+ self.install_dir)
+
+
+ ext_outputs = \
+ self._mutate_outputs (self.distribution.has_ext_modules(),
+ 'build_ext', 'build_lib',
+ self.install_dir)
+
+ return pure_outputs + ext_outputs
+
+ # get_outputs ()
+
+# class install_lib