Commit e5461b6c authored by Benoit Pierre's avatar Benoit Pierre

workaround easy_install bug

Don't reuse `easy_install` command in `Distribution.fetch_build_egg` implementation.

Fix #196.
parent aa41a7a5
...@@ -485,36 +485,30 @@ class Distribution(Distribution_parse_config_files, _Distribution): ...@@ -485,36 +485,30 @@ class Distribution(Distribution_parse_config_files, _Distribution):
def fetch_build_egg(self, req): def fetch_build_egg(self, req):
"""Fetch an egg needed for building""" """Fetch an egg needed for building"""
from setuptools.command.easy_install import easy_install
try: dist = self.__class__({'script_args': ['easy_install']})
cmd = self._egg_fetcher dist.parse_config_files()
cmd.package_index.to_scan = [] opts = dist.get_option_dict('easy_install')
except AttributeError: keep = (
from setuptools.command.easy_install import easy_install 'find_links', 'site_dirs', 'index_url', 'optimize',
dist = self.__class__({'script_args': ['easy_install']}) 'site_dirs', 'allow_hosts'
dist.parse_config_files() )
opts = dist.get_option_dict('easy_install') for key in list(opts):
keep = ( if key not in keep:
'find_links', 'site_dirs', 'index_url', 'optimize', del opts[key] # don't use any other settings
'site_dirs', 'allow_hosts' if self.dependency_links:
) links = self.dependency_links[:]
for key in list(opts): if 'find_links' in opts:
if key not in keep: links = opts['find_links'][1].split() + links
del opts[key] # don't use any other settings opts['find_links'] = ('setup', links)
if self.dependency_links: install_dir = self.get_egg_cache_dir()
links = self.dependency_links[:] cmd = easy_install(
if 'find_links' in opts: dist, args=["x"], install_dir=install_dir,
links = opts['find_links'][1].split() + links exclude_scripts=True,
opts['find_links'] = ('setup', links) always_copy=False, build_directory=None, editable=False,
install_dir = self.get_egg_cache_dir() upgrade=False, multi_version=True, no_report=True, user=False
cmd = easy_install( )
dist, args=["x"], install_dir=install_dir, cmd.ensure_finalized()
exclude_scripts=True,
always_copy=False, build_directory=None, editable=False,
upgrade=False, multi_version=True, no_report=True, user=False
)
cmd.ensure_finalized()
self._egg_fetcher = cmd
return cmd.easy_install(req) return cmd.easy_install(req)
def _set_global_opts_from_features(self): def _set_global_opts_from_features(self):
......
from setuptools import Distribution
from setuptools.extern.six.moves.urllib.request import pathname2url
from setuptools.extern.six.moves.urllib_parse import urljoin
from .textwrap import DALS
from .test_easy_install import make_nspkg_sdist
def test_dist_fetch_build_egg(tmpdir):
"""
Check multiple calls to `Distribution.fetch_build_egg` work as expected.
"""
index = tmpdir.mkdir('index')
index_url = urljoin('file://', pathname2url(str(index)))
def sdist_with_index(distname, version):
dist_dir = index.mkdir(distname)
dist_sdist = '%s-%s.tar.gz' % (distname, version)
make_nspkg_sdist(str(dist_dir.join(dist_sdist)), distname, version)
with dist_dir.join('index.html').open('w') as fp:
fp.write(DALS(
'''
<!DOCTYPE html><html><body>
<a href="{dist_sdist}" rel="internal">{dist_sdist}</a><br/>
</body></html>
'''
).format(dist_sdist=dist_sdist))
sdist_with_index('barbazquux', '3.2.0')
sdist_with_index('barbazquux-runner', '2.11.1')
with tmpdir.join('setup.cfg').open('w') as fp:
fp.write(DALS(
'''
[easy_install]
index_url = {index_url}
'''
).format(index_url=index_url))
reqs = '''
barbazquux-runner
barbazquux
'''.split()
with tmpdir.as_cwd():
dist = Distribution()
resolved_dists = [
dist.fetch_build_egg(r)
for r in reqs
]
assert [dist.key for dist in resolved_dists if dist] == reqs
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