Commit b76a5bf6 authored by tarek's avatar tarek

the parse API needs to return distribute when setuptools is asked

--HG--
branch : distribute
extra : rebase_source : 485e5999425fb57f1f0fce496ffc209a9bfe54e8
parent 4c9daf7b
......@@ -130,29 +130,34 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
was_imported = 'pkg_resources' in sys.modules or \
'setuptools' in sys.modules
try:
import pkg_resources
if not hasattr(pkg_resources, '_distribute'):
fake_setuptools()
raise ImportError
except ImportError:
return _do_download(version, download_base, to_dir, download_delay)
try:
pkg_resources.require("distribute>="+version)
return
except pkg_resources.VersionConflict, e:
if was_imported:
print >>sys.stderr, (
"The required version of distribute (>=%s) is not available, and\n"
"can't be installed while this script is running. Please install\n"
" a more recent version first, using 'easy_install -U distribute'."
"\n\n(Currently using %r)") % (version, e.args[0])
sys.exit(2)
else:
del pkg_resources, sys.modules['pkg_resources'] # reload ok
try:
import pkg_resources
if not hasattr(pkg_resources, '_distribute'):
fake_setuptools()
raise ImportError
except ImportError:
return _do_download(version, download_base, to_dir, download_delay)
except pkg_resources.DistributionNotFound:
return _do_download(version, download_base, to_dir, download_delay)
try:
pkg_resources.require("distribute>="+version)
return
except pkg_resources.VersionConflict, e:
if was_imported:
print >>sys.stderr, (
"The required version of distribute (>=%s) is not available,\n"
"and can't be installed while this script is running. Please\n"
"install a more recent version first, using\n"
"'easy_install -U distribute'."
"\n\n(Currently using %r)") % (version, e.args[0])
sys.exit(2)
else:
del pkg_resources, sys.modules['pkg_resources'] # reload ok
return _do_download(version, download_base, to_dir,
download_delay)
except pkg_resources.DistributionNotFound:
return _do_download(version, download_base, to_dir,
download_delay)
finally:
_create_fake_setuptools_pkg_info(to_dir)
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, delay=15):
......@@ -260,6 +265,9 @@ def _remove_flat_installation(placeholder):
def _after_install(dist):
log.warn('After install bootstrap.')
placeholder = dist.get_command_obj('install').install_purelib
_create_fake_setuptools_pkg_info(placeholder)
def _create_fake_setuptools_pkg_info(placeholder):
if not placeholder or not os.path.exists(placeholder):
log.warn('Could not find the install location')
return
......
......@@ -2486,6 +2486,19 @@ class Requirement:
#@staticmethod
def parse(s):
# if asked for setuptools distribution
# and if distribute is installed, we want to give
# distribute instead
stripped_s = s.replace(' ', '')
stripped_s = stripped_s.strip()
if stripped_s in ('setuptools', 'setuptools==0.6c9',
'setuptools>0.6c9', 'setuptools>=0.6c9'):
reqs = list(parse_requirements('distribute'))
if reqs:
if len(reqs)==1:
# ok we can replace the requirement
return reqs[0]
reqs = list(parse_requirements(s))
if reqs:
if len(reqs)==1:
......
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