Commit 5ef45070 authored by PJ Eby's avatar PJ Eby

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
parent efb23eb7
...@@ -235,14 +235,14 @@ class Installer: ...@@ -235,14 +235,14 @@ class Installer:
"Not a URL, existing file, or requirement spec: %r" % "Not a URL, existing file, or requirement spec: %r" %
(spec,) (spec,)
) )
# process a Requirement # process a Requirement
dist = AvailableDistributions().best_match(spec,[]) dist = AvailableDistributions().best_match(spec,[])
if dist is not None and dist.path.endswith('.egg'): if dist is not None and dist.path.endswith('.egg'):
return dist.path 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): def install_eggs(self, dist_filename):
# .egg dirs or files are already built, so just return them # .egg dirs or files are already built, so just return them
...@@ -351,10 +351,10 @@ class Installer: ...@@ -351,10 +351,10 @@ class Installer:
sys.argv[:] = save_argv 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): ...@@ -492,7 +492,7 @@ class PthDistributions(AvailableDistributions):
URL_SCHEME = re.compile('([-+.a-z0-9]{2,}):',re.I).match URL_SCHEME = re.compile('([-+.a-z0-9]{2,}):',re.I).match
def main(argv): def main(argv, factory=Installer):
from optparse import OptionParser from optparse import OptionParser
parser = OptionParser(usage = "usage: %prog [options] url [url...]") parser = OptionParser(usage = "usage: %prog [options] url [url...]")
...@@ -514,7 +514,7 @@ def main(argv): ...@@ -514,7 +514,7 @@ def main(argv):
raise RuntimeError("No urls, filenames, or requirements specified") raise RuntimeError("No urls, filenames, or requirements specified")
for spec in args: for spec in args:
inst = Installer(options.instdir, options.zip_ok, options.multi) inst = factory(options.instdir, options.zip_ok, options.multi)
try: try:
print "Downloading", spec print "Downloading", spec
downloaded = inst.download(spec) downloaded = inst.download(spec)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment