diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2017-09-03 13:36:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-03 13:36:52 -0400 |
| commit | 776c807b88c89d029c4c9d8dd56852bb2b141dd7 (patch) | |
| tree | b8321ac85e795da11e167449feff93a6deef160e | |
| parent | 09e14c771f8dfd08122c63dc7bc1027d0040c26e (diff) | |
| parent | 37eceeb0a4aab75c54f8e6afb66fd236562ca9f2 (diff) | |
| download | python-setuptools-git-776c807b88c89d029c4c9d8dd56852bb2b141dd7.tar.gz | |
Merge pull request #1127 from benoit-pierre/workaround_easy_install_bug
workaround easy_install bug
| -rw-r--r-- | CHANGES.rst | 4 | ||||
| -rw-r--r-- | setuptools/dist.py | 54 | ||||
| -rw-r--r-- | setuptools/tests/test_dist.py | 46 |
3 files changed, 74 insertions, 30 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 24a3e4d0..9b9d5fe1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,10 @@ v36.4.0 * #1068: Sort files and directories when building eggs for deterministic order. +* #196: Remove caching of easy_install command in fetch_build_egg. + Fixes issue where ``pytest-runner-N.N`` would satisfy the installation + of ``pytest``. + v36.3.0 ------- diff --git a/setuptools/dist.py b/setuptools/dist.py index 084641a8..a2ca8795 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -495,36 +495,30 @@ class Distribution(Distribution_parse_config_files, _Distribution): def fetch_build_egg(self, req): """Fetch an egg needed for building""" - - try: - cmd = self._egg_fetcher - cmd.package_index.to_scan = [] - except AttributeError: - from setuptools.command.easy_install import easy_install - dist = self.__class__({'script_args': ['easy_install']}) - dist.parse_config_files() - opts = dist.get_option_dict('easy_install') - keep = ( - 'find_links', 'site_dirs', 'index_url', 'optimize', - 'site_dirs', 'allow_hosts' - ) - for key in list(opts): - if key not in keep: - del opts[key] # don't use any other settings - if self.dependency_links: - links = self.dependency_links[:] - if 'find_links' in opts: - links = opts['find_links'][1].split() + links - opts['find_links'] = ('setup', links) - install_dir = self.get_egg_cache_dir() - cmd = easy_install( - dist, args=["x"], install_dir=install_dir, - 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 + from setuptools.command.easy_install import easy_install + dist = self.__class__({'script_args': ['easy_install']}) + dist.parse_config_files() + opts = dist.get_option_dict('easy_install') + keep = ( + 'find_links', 'site_dirs', 'index_url', 'optimize', + 'site_dirs', 'allow_hosts' + ) + for key in list(opts): + if key not in keep: + del opts[key] # don't use any other settings + if self.dependency_links: + links = self.dependency_links[:] + if 'find_links' in opts: + links = opts['find_links'][1].split() + links + opts['find_links'] = ('setup', links) + install_dir = self.get_egg_cache_dir() + cmd = easy_install( + dist, args=["x"], install_dir=install_dir, + exclude_scripts=True, + always_copy=False, build_directory=None, editable=False, + upgrade=False, multi_version=True, no_report=True, user=False + ) + cmd.ensure_finalized() return cmd.easy_install(req) def _set_global_opts_from_features(self): diff --git a/setuptools/tests/test_dist.py b/setuptools/tests/test_dist.py new file mode 100644 index 00000000..435ffec0 --- /dev/null +++ b/setuptools/tests/test_dist.py @@ -0,0 +1,46 @@ +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 |
