From 5ef4507014a29885231dba9c2d3bb6c888003777 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sun, 29 May 2005 07:13:43 +0000 Subject: Add support for using Installer subclasses, especially ones with support for searching a package database. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041023 --- easy_install.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'easy_install.py') diff --git a/easy_install.py b/easy_install.py index 36482fe4..eb294d01 100755 --- a/easy_install.py +++ b/easy_install.py @@ -235,14 +235,14 @@ class Installer: "Not a URL, existing file, or requirement spec: %r" % (spec,) ) + # process a Requirement dist = AvailableDistributions().best_match(spec,[]) if dist is not None and dist.path.endswith('.egg'): return dist.path - # TODO: search here for a distro to download + return self.download(self._find_package(spec)) - raise DistributionNotFound(spec) def install_eggs(self, dist_filename): # .egg dirs or files are already built, so just return them @@ -351,10 +351,10 @@ class Installer: sys.argv[:] = save_argv - - - - + def _find_package(self, req): + # TODO: search here for a distro to download, matching Requirement + # 'req' and return the package URL or filename + raise DistributionNotFound(spec) @@ -492,7 +492,7 @@ class PthDistributions(AvailableDistributions): URL_SCHEME = re.compile('([-+.a-z0-9]{2,}):',re.I).match -def main(argv): +def main(argv, factory=Installer): from optparse import OptionParser parser = OptionParser(usage = "usage: %prog [options] url [url...]") @@ -514,7 +514,7 @@ def main(argv): raise RuntimeError("No urls, filenames, or requirements specified") for spec in args: - inst = Installer(options.instdir, options.zip_ok, options.multi) + inst = factory(options.instdir, options.zip_ok, options.multi) try: print "Downloading", spec downloaded = inst.download(spec) -- cgit v1.2.1