diff options
author | PJ Eby <distutils-sig@python.org> | 2006-02-07 16:43:41 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2006-02-07 16:43:41 +0000 |
commit | ca9ccbf6e73daf553bc41d5abd02f8ebf0d44b45 (patch) | |
tree | 5f9b41a03b6a284fa3b4a9f449f547846c982890 /setuptools/package_index.py | |
parent | 48dd1efa65437eb6692ac20be616a6ea7989236c (diff) | |
download | external_python_setuptools-ca9ccbf6e73daf553bc41d5abd02f8ebf0d44b45.tar.gz external_python_setuptools-ca9ccbf6e73daf553bc41d5abd02f8ebf0d44b45.tar.bz2 external_python_setuptools-ca9ccbf6e73daf553bc41d5abd02f8ebf0d44b45.zip |
The ``--always-copy`` option now skips "system" and "development" eggs
since they can't be reliably copied. Note that this may cause EasyInstall
to choose an older version of a package than what you expected, or it may
cause downloading and installation of a fresh version of what's already
installed.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4042260
Diffstat (limited to 'setuptools/package_index.py')
-rwxr-xr-x | setuptools/package_index.py | 69 |
1 files changed, 55 insertions, 14 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 2813631e..669692b6 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -337,12 +337,12 @@ class PackageIndex(Environment): automatically created alongside the downloaded file. If `spec` is a ``Requirement`` object or a string containing a - project/version requirement spec, this method is equivalent to - the ``fetch()`` method. If `spec` is a local, existing file or - directory name, it is simply returned unchanged. If `spec` is a URL, - it is downloaded to a subpath of `tmpdir`, and the local filename is - returned. Various errors may be raised if a problem occurs during - downloading. + project/version requirement spec, this method returns the location of + a matching distribution (possibly after downloading it to `tmpdir`). + If `spec` is a locally existing file or directory name, it is simply + returned unchanged. If `spec` is a URL, it is downloaded to a subpath + of `tmpdir`, and the local filename is returned. Various errors may be + raised if a problem occurs during downloading. """ if not isinstance(spec,Requirement): scheme = URL_SCHEME(spec) @@ -364,31 +364,49 @@ class PackageIndex(Environment): "Not a URL, existing file, or requirement spec: %r" % (spec,) ) - return self.fetch(spec, tmpdir) + return getattr(self.fetch_distribution(spec, tmpdir),'location',None) - def fetch(self, requirement, tmpdir, force_scan=False, source=False): - """Obtain a file suitable for fulfilling `requirement` + def fetch_distribution(self, + requirement, tmpdir, force_scan=False, source=False, develop_ok=False + ): + """Obtain a distribution suitable for fulfilling `requirement` `requirement` must be a ``pkg_resources.Requirement`` instance. If necessary, or if the `force_scan` flag is set, the requirement is searched for in the (online) package index as well as the locally installed packages. If a distribution matching `requirement` is found, - the return value is the same as if you had called the ``download()`` - method with the matching distribution's URL. If no matching - distribution is found, returns ``None``. + the returned distribution's ``location`` is the value you would have + gotten from calling the ``download()`` method with the matching + distribution's URL or filename. If no matching distribution is found, + ``None`` is returned. If the `source` flag is set, only source distributions and source - checkout links will be considered. + checkout links will be considered. Unless the `develop_ok` flag is + set, development and system eggs (i.e., those using the ``.egg-info`` + format) will be ignored. """ + # process a Requirement self.info("Searching for %s", requirement) + skipped = {} def find(req): + # Find a matching distribution; may be called more than once + for dist in self[req.key]: + + if dist.precedence==DEVELOP_DIST and not develop_ok: + if dist not in skipped: + self.warn("Skipping development or system egg: %s",dist) + skipped[dist] = 1 + continue + if dist in req and (dist.precedence<=SOURCE_DIST or not source): self.info("Best match: %s", dist) - return self.download(dist.location, tmpdir) + return dist.clone( + location=self.download(dist.location, tmpdir) + ) if force_scan: self.find_packages(requirement) @@ -407,6 +425,29 @@ class PackageIndex(Environment): ) return dist + def fetch(self, requirement, tmpdir, force_scan=False, source=False): + """Obtain a file suitable for fulfilling `requirement` + + DEPRECATED; use the ``fetch_distribution()`` method now instead. For + backward compatibility, this routine is identical but returns the + ``location`` of the downloaded distribution instead of a distribution + object. + """ + dist = self.fetch_dist(requirement,tmpdir,force_scan,source) + if dist is not None: + return dist.location + return None + + + + + + + + + + + def gen_setup(self, filename, fragment, tmpdir): match = EGG_FRAGMENT.match(fragment); #import pdb; pdb.set_trace() |