Skip to content

Commit ef4cd29

Browse files
committed
Merge pull request #2908 from pypa/debt/remove-easy-install
Disable easy_install command and remove sandbox functionality.
2 parents 9653305 + 85bbad4 commit ef4cd29

File tree

7 files changed

+8
-1547
lines changed

7 files changed

+8
-1547
lines changed

newsfragments/2908.removal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed support for the easy_install command including the sandbox module.

setuptools/command/easy_install.py

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@
5656
)
5757
from setuptools import Command
5858
from setuptools.archive_util import unpack_archive
59-
from setuptools.command import bdist_egg, egg_info, setopt
59+
from setuptools.command import bdist_egg, setopt
6060
from setuptools.package_index import URL_SCHEME, PackageIndex, parse_requirement_arg
61-
from setuptools.sandbox import run_setup
6261
from setuptools.warnings import SetuptoolsDeprecationWarning, SetuptoolsWarning
6362
from setuptools.wheel import Wheel
6463

@@ -424,33 +423,7 @@ def expand_dirs(self) -> None:
424423
self._expand_attrs(dirs)
425424

426425
def run(self, show_deprecation: bool = True) -> None:
427-
if show_deprecation:
428-
self.announce(
429-
"WARNING: The easy_install command is deprecated "
430-
"and will be removed in a future version.",
431-
log.WARN,
432-
)
433-
if self.verbose != self.distribution.verbose:
434-
log.set_verbosity(self.verbose)
435-
try:
436-
for spec in self.args:
437-
self.easy_install(spec, not self.no_deps)
438-
if self.record:
439-
outputs = self.outputs
440-
if self.root: # strip any package prefix
441-
root_len = len(self.root)
442-
for counter in range(len(outputs)):
443-
outputs[counter] = outputs[counter][root_len:]
444-
from distutils import file_util
445-
446-
self.execute(
447-
file_util.write_file,
448-
(self.record, outputs),
449-
f"writing list of installed files to '{self.record}'",
450-
)
451-
self.warn_deprecated_options()
452-
finally:
453-
log.set_verbosity(self.distribution.verbose)
426+
raise RuntimeError("easy_install command is disabled")
454427

455428
def pseudo_tempname(self):
456429
"""Return a pseudo-tempname base in the install directory.
@@ -1175,23 +1148,8 @@ def report_editable(self, spec, setup_script):
11751148
python = sys.executable
11761149
return '\n' + self.__editable_msg % locals()
11771150

1178-
def run_setup(self, setup_script, setup_base, args) -> None:
1179-
sys.modules.setdefault('distutils.command.bdist_egg', bdist_egg)
1180-
sys.modules.setdefault('distutils.command.egg_info', egg_info)
1181-
1182-
args = list(args)
1183-
if self.verbose > 2:
1184-
v = 'v' * (self.verbose - 1)
1185-
args.insert(0, '-' + v)
1186-
elif self.verbose < 2:
1187-
args.insert(0, '-q')
1188-
if self.dry_run:
1189-
args.insert(0, '-n')
1190-
log.info("Running %s %s", setup_script[len(setup_base) + 1 :], ' '.join(args))
1191-
try:
1192-
run_setup(setup_script, args)
1193-
except SystemExit as v:
1194-
raise DistutilsError(f"Setup script exited with {v.args[0]}") from v
1151+
def run_setup(self, setup_script, setup_base, args) -> NoReturn:
1152+
raise NotImplementedError("easy_install support has been removed")
11951153

11961154
def build_and_install(self, setup_script, setup_base):
11971155
args = ['bdist_egg', '--dist-dir']

setuptools/command/install.py

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
from __future__ import annotations
22

3-
import glob
43
import inspect
54
import platform
65
from collections.abc import Callable
7-
from typing import TYPE_CHECKING, Any, ClassVar, cast
8-
9-
import setuptools
6+
from typing import TYPE_CHECKING, Any, ClassVar
107

118
from ..dist import Distribution
129
from ..warnings import SetuptoolsDeprecationWarning, SetuptoolsWarning
13-
from .bdist_egg import bdist_egg as bdist_egg_cls
1410

1511
import distutils.command.install as orig
1612
from distutils.errors import DistutilsArgError
@@ -144,37 +140,7 @@ def _called_from_setup(run_frame):
144140
return False
145141

146142
def do_egg_install(self) -> None:
147-
easy_install = self.distribution.get_command_class('easy_install')
148-
149-
cmd = cast(
150-
# We'd want to cast easy_install as type[easy_install_cls] but a bug in
151-
# mypy makes it think easy_install() returns a Command on Python 3.12+
152-
# https://github.com/python/mypy/issues/18088
153-
easy_install_cls,
154-
easy_install( # type: ignore[call-arg]
155-
self.distribution,
156-
args="x",
157-
root=self.root,
158-
record=self.record,
159-
),
160-
)
161-
cmd.ensure_finalized() # finalize before bdist_egg munges install cmd
162-
cmd.always_copy_from = '.' # make sure local-dir eggs get installed
163-
164-
# pick up setup-dir .egg files only: no .egg-info
165-
cmd.package_index.scan(glob.glob('*.egg'))
166-
167-
self.run_command('bdist_egg')
168-
bdist_egg = cast(bdist_egg_cls, self.distribution.get_command_obj('bdist_egg'))
169-
args = [bdist_egg.egg_output]
170-
171-
if setuptools.bootstrap_install_from:
172-
# Bootstrap self-installation of setuptools
173-
args.insert(0, setuptools.bootstrap_install_from)
174-
175-
cmd.args = args
176-
cmd.run(show_deprecation=False)
177-
setuptools.bootstrap_install_from = None
143+
raise NotImplementedError("Support for egg-based install has been removed.")
178144

179145

180146
# XXX Python 3.1 doesn't see _nc if this is inside the class

0 commit comments

Comments
 (0)