diff options
| author | PJ Eby <distutils-sig@python.org> | 2005-07-12 05:31:36 +0000 |
|---|---|---|
| committer | PJ Eby <distutils-sig@python.org> | 2005-07-12 05:31:36 +0000 |
| commit | 3efcdec07fa19acd77cb3a5a38ef5052b509681a (patch) | |
| tree | d506ac75836fa123fb75b5c1a91cf3fb2bac0382 | |
| parent | cd6fbcf869468bc61cc071b2751d858054ce8549 (diff) | |
| download | python-setuptools-git-3efcdec07fa19acd77cb3a5a38ef5052b509681a.tar.gz | |
Fix bugs and implement features reported/requested by folks on the
Distutils-SIG.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041117
| -rwxr-xr-x | EasyInstall.txt | 28 | ||||
| -rw-r--r-- | pkg_resources.py | 18 | ||||
| -rwxr-xr-x | setup.py | 2 | ||||
| -rwxr-xr-x | setuptools.txt | 11 | ||||
| -rwxr-xr-x | setuptools/package_index.py | 83 |
5 files changed, 102 insertions, 40 deletions
diff --git a/EasyInstall.txt b/EasyInstall.txt index 435ead05..136c1263 100755 --- a/EasyInstall.txt +++ b/EasyInstall.txt @@ -495,15 +495,18 @@ Command-Line Options the PEAK downloads page, but ignore the other download links on that page. If all requested packages can be found using links on the specified download pages, the Python Package Index will *not* be consulted. You can - use ``file:`` URLs to reference a local filename. - - You may specify multiple URLs with this option, separated by whitespace. - Note that on the command line, you will probably have to surround the URLs - with quotes, so that they are recognized as a single option value. You can - also specify URLs in a configuration file; see `Configuration Files`_, - above; but note that this means the specified pages will be downloaded - every time you use EasyInstall (unless overridden on the command line) and - thus may make startup slower. + use a ``file:`` URL to reference a local HTML file containing links, or you + can just use the name of a directory containing "distribution files" + (source archives, eggs, Windows installers, etc.), and EasyInstall will + then be aware of the files available there. + + You may specify multiple URLs or directories with this option, separated by + whitespace. Note that on the command line, you will probably have to + surround the URL list with quotes, so that it is recognized as a single + option value. You can also specify URLs in a configuration file; see + `Configuration Files`_, above; but note that this means the specified pages + will be downloaded every time you use EasyInstall (unless overridden on the + command line) and thus may make startup slower. ``--delete-conflicting, -D`` (New in 0.5a9) If you are replacing a package that was previously installed *without* @@ -593,6 +596,13 @@ Known Issues in Exemaker. So, don't use Exemaker to wrap ``easy_install.py``, or at any rate don't expect it to work with all packages. +0.5a10 + * Put the ``easy_install`` module back in as a module, as it's needed for + ``python -m`` to run it! + + * Allow ``--find-links/-f`` to accept local directories or filenames as well + as URLs. + 0.5a9 * EasyInstall now automatically detects when an "unmanaged" package or module is going to be on ``sys.path`` ahead of a package you're installing, diff --git a/pkg_resources.py b/pkg_resources.py index 583a5c84..a16b67b4 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -69,17 +69,17 @@ def register_loader_type(loader_type, provider_factory): def get_provider(moduleName): """Return an IResourceProvider for the named module""" - module = sys.modules[moduleName] + try: + module = sys.modules[moduleName] + except KeyError: + __import__(moduleName) + module = sys.modules[moduleName] loader = getattr(module, '__loader__', None) return _find_adapter(_provider_factories, loader)(module) - - - - def get_platform(): """Return this platform's string for platform-specific distributions @@ -984,6 +984,7 @@ def StringIO(*args, **kw): def find_nothing(importer,path_item): return () + register_finder(object,find_nothing) def find_on_path(importer,path_item): @@ -1004,7 +1005,7 @@ def find_on_path(importer,path_item): fullpath = os.path.join(path_item, entry) lower = entry.lower() if lower.endswith('.egg'): - for dist in find_on_path(importer,fullpath): + for dist in find_distributions(fullpath): yield dist elif lower.endswith('.egg-info'): if os.path.isdir(fullpath): @@ -1017,12 +1018,11 @@ def find_on_path(importer,path_item): if not line.strip(): continue for item in find_distributions(line.rstrip()): yield item - elif path_item.lower().endswith('.egg'): # packed egg - metadata = EggMetadata(zipimport.zipimporter(path_item)) - yield Distribution.from_filename(path_item, metadata=metadata) register_finder(ImpWrapper,find_on_path) + + _namespace_handlers = {} _namespace_packages = {} @@ -33,7 +33,7 @@ setup( test_suite = 'setuptools.tests.test_suite', packages = find_packages(), - py_modules = ['pkg_resources'], + py_modules = ['pkg_resources', 'easy_install'], scripts = ['easy_install.py'], zip_safe = True, diff --git a/setuptools.txt b/setuptools.txt index 12bd0386..5fb288b4 100755 --- a/setuptools.txt +++ b/setuptools.txt @@ -1334,6 +1334,17 @@ XXX Release Notes/Change History ---------------------------- +0.5a10 + * Fix a problem with ``pkg_resources`` being confused by non-existent eggs on + ``sys.path`` (e.g. if a user deletes an egg without removing it from the + ``easy-install.pth`` file. + + * Fix a problem with "basket" support in ``pkg_resources``, where egg-finding + never actually went inside ``.egg`` files. + + * Made ``pkg_resources`` import the module you request resources from, if it's + not already imported. + 0.5a9 * Include ``svn:externals`` directories in source distributions as well as normal subversion-controlled files and directories. diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 21d37cf9..5412fd1f 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -44,27 +44,32 @@ def distros_for_url(url, metadata=None): path = urlparse.urlparse(url)[2] base = urllib2.unquote(path.split('/')[-1]) - if base.endswith('.egg.zip'): - base = base[:-4] # strip the .zip + return distros_for_filename(url, base, metadata) - if base.endswith('.egg'): - dist = Distribution.from_filename(base, metadata) - dist.path = url + +def distros_for_filename(url_or_path, basename, metadata=None): + """Yield egg or source distribution objects based on basename""" + if basename.endswith('.egg.zip'): + basename = basename[:-4] # strip the .zip + + if basename.endswith('.egg'): + dist = Distribution.from_filename(basename, metadata) + dist.path = url_or_path return [dist] # only one, unambiguous interpretation - if base.endswith('.exe'): - win_base, py_ver = parse_bdist_wininst(base) + if basename.endswith('.exe'): + win_base, py_ver = parse_bdist_wininst(basename) if win_base is not None: return interpret_distro_name( - url, win_base, metadata, py_ver, BINARY_DIST, "win32" + url_or_path, win_base, metadata, py_ver, BINARY_DIST, "win32" ) # Try source distro extensions (.zip, .tgz, etc.) # for ext in EXTENSIONS: - if base.endswith(ext): - base = base[:-len(ext)] - return interpret_distro_name(url, base, metadata) + if basename.endswith(ext): + basename = basename[:-len(ext)] + return interpret_distro_name(url_or_path, basename, metadata) return [] # no extension matched @@ -75,12 +80,7 @@ def distros_for_url(url, metadata=None): - - - - - -def interpret_distro_name(url, base, metadata, +def interpret_distro_name(url_or_path, basename, metadata, py_version=None, distro_type=SOURCE_DIST, platform=None ): @@ -96,10 +96,10 @@ def interpret_distro_name(url, base, metadata, # in the long run PyPI and the distutils should go for "safe" names and # versions in distribution archive names (sdist and bdist). - parts = base.split('-') + parts = basename.split('-') for p in range(1,len(parts)+1): yield Distribution( - url, metadata, '-'.join(parts[:p]), '-'.join(parts[p:]), + url_or_path, metadata, '-'.join(parts[:p]), '-'.join(parts[p:]), py_version=py_version, distro_type = distro_type, platform = platform ) @@ -132,12 +132,35 @@ class PackageIndex(AvailableDistributions): self.package_pages = {} def process_url(self, url, retrieve=False): + """Evaluate a URL as a possible download, and maybe retrieve it""" + if url in self.scanned_urls and not retrieve: return self.scanned_urls[url] = True - dists = list(distros_for_url(url)) - if dists: self.debug("Found link: %s", url) + + if not URL_SCHEME(url): + # process filenames or directories + if os.path.isfile(url): + dists = list( + distros_for_filename( + os.path.realpath(url), os.path.basename(url) + ) + ) + elif os.path.isdir(url): + url = os.path.realpath(url) + for item in os.listdir(url): + self.process_url(os.path.join(url,item)) + return + else: + self.warn("Not found: %s", url) + return + else: + dists = list(distros_for_url(url)) + + if dists: + self.debug("Found link: %s", url) + if dists or not retrieve or url in self.fetched_urls: for dist in dists: @@ -148,6 +171,7 @@ class PackageIndex(AvailableDistributions): self.info("Reading %s", url) f = self.open_url(url) self.fetched_urls[url] = self.fetched_urls[f.url] = True + if 'html' not in f.headers['content-type'].lower(): f.close() # not html, we can't process it return @@ -162,6 +186,23 @@ class PackageIndex(AvailableDistributions): link = urlparse.urljoin(base, match.group(1)) self.process_url(link) + + + + + + + + + + + + + + + + + def process_index(self,url,page): """Process the contents of a PyPI page""" |
