aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/package_index.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-06-15 02:23:48 +0000
committerPJ Eby <distutils-sig@python.org>2005-06-15 02:23:48 +0000
commit645693ba88a2bd2beacbd50d57a5608960190a74 (patch)
tree9ef6012a9f15c0761b22a1d2a8169543f49b3ab3 /setuptools/package_index.py
parent5a9445cd57c60bb47451d8a88ec12a7a865013b7 (diff)
downloadexternal_python_setuptools-645693ba88a2bd2beacbd50d57a5608960190a74.tar.gz
external_python_setuptools-645693ba88a2bd2beacbd50d57a5608960190a74.tar.bz2
external_python_setuptools-645693ba88a2bd2beacbd50d57a5608960190a74.zip
Add support for installing from .win32.exe's created by distutils (by
converting them to eggs). Bump version to 0.5a1. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041070
Diffstat (limited to 'setuptools/package_index.py')
-rwxr-xr-xsetuptools/package_index.py75
1 files changed, 58 insertions, 17 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
index be40df9c..d9d2fc00 100755
--- a/setuptools/package_index.py
+++ b/setuptools/package_index.py
@@ -9,13 +9,25 @@ URL_SCHEME = re.compile('([-+.a-z0-9]{2,}):',re.I).match
EXTENSIONS = ".tar.gz .tar.bz2 .tar .zip .tgz".split()
__all__ = [
- 'PackageIndex', 'distros_for_url',
+ 'PackageIndex', 'distros_for_url', 'parse_bdist_wininst',
+ 'interpret_distro_name',
]
+def parse_bdist_wininst(name):
+ """Return (base,pyversion) or (None,None) for possible .exe name"""
+ lower = name.lower()
+ base, py_ver = None, None
+ if lower.endswith('.exe'):
+ if lower.endswith('.win32.exe'):
+ base = name[:-10]
+ elif lower[-16:].startswith('.win32-py'):
+ py_ver = base[-7:-4]
+ base = name[:-16]
+ return base,py_ver
@@ -27,8 +39,32 @@ __all__ = [
+def distros_for_url(url, metadata=None):
+ """Yield egg or source distribution objects that might be found at a URL"""
+ path = urlparse.urlparse(url)[2]
+ base = urllib2.unquote(path.split('/')[-1])
+
+ if base.endswith('.egg'):
+ dist = Distribution.from_filename(base, metadata)
+ dist.path = url
+ return [dist] # only one, unambiguous interpretation
+ if base.endswith('.exe'):
+ win_base, py_ver = parse_bdist_wininst(name)
+ if win_base is not None:
+ return interpret_distro_name(
+ url, 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)
+
+ return [] # no extension matched
@@ -39,24 +75,14 @@ __all__ = [
-def distros_for_url(url, metadata=None):
- """Yield egg or source distribution objects that might be found at a URL"""
- path = urlparse.urlparse(url)[2]
- base = urllib2.unquote(path.split('/')[-1])
- if base.endswith('.egg'):
- dist = Distribution.from_filename(base, metadata)
- dist.path = url
- yield dist
- return # only one, unambiguous interpretation
- for ext in EXTENSIONS:
- if base.endswith(ext):
- base = base[:-len(ext)]
- break
- else:
- return # no extension matched
+
+
+def interpret_distro_name(url, base, metadata,
+ py_version=None, distro_type=SOURCE_DIST, platform=None
+):
# Generate alternative interpretations of a source distro name
# Because some packages are ambiguous as to name/versions split
@@ -74,12 +100,27 @@ def distros_for_url(url, metadata=None):
for p in range(1,len(parts)+1):
yield Distribution(
url, metadata, '-'.join(parts[:p]), '-'.join(parts[p:]),
- distro_type = SOURCE_DIST
+ py_version=py_version, distro_type = distro_type,
+ platform = platform
)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
class PackageIndex(AvailableDistributions):
"""A distribution index that scans web pages for download URLs"""