Skip to content

Commit

Permalink
Remove support for easy_install-based downloads for fetch_build_eggs …
Browse files Browse the repository at this point in the history
…(setup_requires).
  • Loading branch information
jaraco committed Jan 17, 2021
1 parent 6b44f94 commit fbb7054
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 56 deletions.
46 changes: 1 addition & 45 deletions setuptools/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from distutils.errors import DistutilsError

import pkg_resources
from setuptools.command.easy_install import easy_install
from setuptools.wheel import Wheel


Expand All @@ -19,54 +18,11 @@ def _fixup_find_links(find_links):
return find_links


def _legacy_fetch_build_egg(dist, req):
"""Fetch an egg needed for building.
Legacy path using EasyInstall.
"""
tmp_dist = dist.__class__({'script_args': ['easy_install']})
opts = tmp_dist.get_option_dict('easy_install')
opts.clear()
opts.update(
(k, v)
for k, v in dist.get_option_dict('easy_install').items()
if k in (
# don't use any other settings
'find_links', 'site_dirs', 'index_url',
'optimize', 'site_dirs', 'allow_hosts',
))
if dist.dependency_links:
links = dist.dependency_links[:]
if 'find_links' in opts:
links = _fixup_find_links(opts['find_links'][1]) + links
opts['find_links'] = ('setup', links)
install_dir = dist.get_egg_cache_dir()
cmd = easy_install(
tmp_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 fetch_build_egg(dist, req): # noqa: C901 # is too complex (16) # FIXME
"""Fetch an egg needed for building.
Use pip/wheel to fetch/build a wheel."""
# Check pip is available.
try:
pkg_resources.get_distribution('pip')
except pkg_resources.DistributionNotFound:
dist.announce(
'WARNING: The pip package is not available, falling back '
'to EasyInstall for handling setup_requires/test_requires; '
'this is deprecated and will be removed in a future version.',
log.WARN
)
return _legacy_fetch_build_egg(dist, req)
# Warn if wheel is not.
# Warn if wheel is not available
try:
pkg_resources.get_distribution('wheel')
except pkg_resources.DistributionNotFound:
Expand Down
10 changes: 4 additions & 6 deletions setuptools/tests/test_easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,10 +742,10 @@ def test_setup_requires_with_python_requires(self, monkeypatch, tmpdir):
assert eggs == ['dep 1.0']

@pytest.mark.parametrize(
'use_legacy_installer,with_dependency_links_in_setup_py',
itertools.product((False, True), (False, True)))
'with_dependency_links_in_setup_py',
(False, True))
def test_setup_requires_with_find_links_in_setup_cfg(
self, monkeypatch, use_legacy_installer,
self, monkeypatch,
with_dependency_links_in_setup_py):
monkeypatch.setenv(str('PIP_RETRIES'), str('0'))
monkeypatch.setenv(str('PIP_TIMEOUT'), str('0'))
Expand All @@ -767,11 +767,9 @@ def test_setup_requires_with_find_links_in_setup_cfg(
fp.write(DALS(
'''
from setuptools import installer, setup
if {use_legacy_installer}:
installer.fetch_build_egg = installer._legacy_fetch_build_egg
setup(setup_requires='python-xlib==42',
dependency_links={dependency_links!r})
''').format(use_legacy_installer=use_legacy_installer, # noqa
''').format(
dependency_links=dependency_links))
with open(test_setup_cfg, 'w') as fp:
fp.write(DALS(
Expand Down
5 changes: 0 additions & 5 deletions setuptools/tests/test_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ def test_test_command_install_requirements(virtualenv, tmpdir):
_check_test_command_install_requirements(virtualenv, tmpdir)


def test_test_command_install_requirements_when_using_easy_install(
bare_virtualenv, tmpdir):
_check_test_command_install_requirements(bare_virtualenv, tmpdir)


def test_no_missing_dependencies(bare_virtualenv):
"""
Quick and dirty test to ensure all external dependencies are vendored.
Expand Down

0 comments on commit fbb7054

Please sign in to comment.