summaryrefslogtreecommitdiff
path: root/setuptools/command/depends.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2004-03-20 20:52:12 +0000
committerPJ Eby <distutils-sig@python.org>2004-03-20 20:52:12 +0000
commit7ce55cabc53fe2c1378446ba0557e5f716c0cd31 (patch)
tree6ae85cd0c23933ddfa883e131aabd2fe398263be /setuptools/command/depends.py
parent8423e1ed14ac1691c2863c6e8cac9230cf558d7b (diff)
downloadpython-setuptools-git-7ce55cabc53fe2c1378446ba0557e5f716c0cd31.tar.gz
Flesh out 'depends' command to display dependencies' status, and halt if
all requirements aren't met. (Also, check planned install location for the dependencies, as well as checking sys.path.) Also: * Allow 'Feature()' objects to include 'Require()' objects, so that dependencies can be optional * 'Require()' objects can set a homepage, whose URL will be displayed by the 'depends' command if the dependency needs to be installed. * Misc. fixes/refactoring of version validation to properly handle "unknown" versions, and to decouple version fetching from version checking. * Updated TODO to remove various completed items. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4040876
Diffstat (limited to 'setuptools/command/depends.py')
-rw-r--r--setuptools/command/depends.py67
1 files changed, 61 insertions, 6 deletions
diff --git a/setuptools/command/depends.py b/setuptools/command/depends.py
index e149faca..8917c83d 100644
--- a/setuptools/command/depends.py
+++ b/setuptools/command/depends.py
@@ -1,7 +1,9 @@
from distutils.cmd import Command
-import os
+import os, sys
+
class depends(Command):
+
"""Download and install dependencies, if needed"""
description = "download and install dependencies, if needed"
@@ -13,15 +15,68 @@ class depends(Command):
"ignore options that won't be passed to child setup scripts"),
]
+ path_attrs = [
+ # Note: these must be in *reverse* order, as they are pushed onto the
+ # *front* of a copy of sys.path.
+ ('install','install_libbase'), # installation base if extra_path
+ ('install_lib','install_dir'), # where modules are installed
+ ]
+
+
def initialize_options(self):
self.temp = None
- self.install_purelib = self.install_platlib = None
- self.install_lib = self.install_libbase = None
- self.install_scripts = self.install_data = self.install_headers = None
- self.compiler = self.debug = self.force = None
def finalize_options(self):
self.set_undefined_options('build',('build_temp', 'temp'))
+ self.set_search_path()
+
+ def set_search_path(self):
+ """Determine paths to check for installed dependencies"""
+ path = sys.path[:] # copy sys path
+ for cmd,attr in self.path_attrs:
+ dir = getattr(self.get_finalized_command(cmd),attr,None)
+ if dir and dir not in path:
+ path.insert(0,dir) # prepend
+ self.search_path = path
def run(self):
- self.announce("downloading and building here")
+ self.announce("checking for installed dependencies")
+ needed = [
+ dep for dep in self.distribution.requires if self.is_needed(dep)
+ ]
+ if not needed:
+ self.announce("all dependencies are present and up-to-date")
+ return
+
+ # Alert the user to missing items
+ fmt = "\t%s\t%s\n"
+ items = [fmt % (dep.full_name(),dep.homepage) for dep in needed]
+ items.insert(0,"Please install the following packages first:\n")
+ items.append('')
+ raise SystemExit('\n'.join(items)) # dump msg to stderr and exit
+
+
+ def is_needed(self,dep):
+ """Does the specified dependency need to be installed/updated?"""
+
+ self.announce("searching for "+dep.full_name())
+ version = dep.get_version(self.search_path)
+
+ if version is None:
+ self.announce(name+" not found!")
+ return True
+
+ if str(version)=="unknown":
+ status = dep.name+" is installed"
+ else:
+ status = dep.name+" version "+str(version)+" found"
+
+ if dep.version_ok(version):
+ self.announce(status+" (OK)")
+ return False
+ else:
+ self.announce(status+" (update needed)")
+ return True
+
+
+