Skip to content

Commit bc3feef

Browse files
committed
Remove setup.py install legacy
1 parent 48986a6 commit bc3feef

File tree

6 files changed

+16
-273
lines changed

6 files changed

+16
-273
lines changed

src/pip/_internal/exceptions.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -361,20 +361,6 @@ def __str__(self) -> str:
361361
)
362362

363363

364-
class LegacyInstallFailure(DiagnosticPipError):
365-
"""Error occurred while executing `setup.py install`"""
366-
367-
reference = "legacy-install-failure"
368-
369-
def __init__(self, package_details: str) -> None:
370-
super().__init__(
371-
message="Encountered error while trying to install package.",
372-
context=package_details,
373-
hint_stmt="See above for output from the failure.",
374-
note_stmt="This is an issue with the package mentioned above, not pip.",
375-
)
376-
377-
378364
class InstallationSubprocessError(DiagnosticPipError, InstallationError):
379365
"""A subprocess call failed."""
380366

src/pip/_internal/operations/install/legacy.py

Lines changed: 0 additions & 117 deletions
This file was deleted.

src/pip/_internal/req/req_install.py

Lines changed: 16 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from pip._vendor.pyproject_hooks import BuildBackendHookCaller
2121

2222
from pip._internal.build_env import BuildEnvironment, NoOpBuildEnvironment
23-
from pip._internal.exceptions import InstallationError, LegacyInstallFailure
23+
from pip._internal.exceptions import InstallationError
2424
from pip._internal.locations import get_scheme
2525
from pip._internal.metadata import (
2626
BaseDistribution,
@@ -39,11 +39,10 @@
3939
from pip._internal.operations.install.editable_legacy import (
4040
install_editable as install_editable_legacy,
4141
)
42-
from pip._internal.operations.install.legacy import install as install_legacy
4342
from pip._internal.operations.install.wheel import install_wheel
4443
from pip._internal.pyproject import load_pyproject_toml, make_pyproject_path
4544
from pip._internal.req.req_uninstall import UninstallPathSet
46-
from pip._internal.utils.deprecation import LegacyInstallReason, deprecated
45+
from pip._internal.utils.deprecation import deprecated
4746
from pip._internal.utils.hashes import Hashes
4847
from pip._internal.utils.misc import (
4948
ConfiguredBuildBackendHookCaller,
@@ -93,7 +92,6 @@ def __init__(
9392
self.constraint = constraint
9493
self.editable = editable
9594
self.permit_editable_wheels = permit_editable_wheels
96-
self.legacy_install_reason: Optional[LegacyInstallReason] = None
9795

9896
# source_dir is the local directory where the linked requirement is
9997
# located, or unpacked. In case unpacking is needed, creating and
@@ -757,10 +755,9 @@ def install(
757755
prefix=prefix,
758756
)
759757

760-
global_options = global_options if global_options is not None else []
761758
if self.editable and not self.is_wheel:
762759
install_editable_legacy(
763-
global_options=global_options,
760+
global_options=global_options if global_options is not None else [],
764761
prefix=prefix,
765762
home=home,
766763
use_user_site=use_user_site,
@@ -773,66 +770,20 @@ def install(
773770
self.install_succeeded = True
774771
return
775772

776-
if self.is_wheel:
777-
assert self.local_file_path
778-
install_wheel(
779-
self.name,
780-
self.local_file_path,
781-
scheme=scheme,
782-
req_description=str(self.req),
783-
pycompile=pycompile,
784-
warn_script_location=warn_script_location,
785-
direct_url=self.download_info if self.original_link else None,
786-
requested=self.user_supplied,
787-
)
788-
self.install_succeeded = True
789-
return
790-
791-
# TODO: Why don't we do this for editable installs?
792-
793-
# Extend the list of global options passed on to
794-
# the setup.py call with the ones from the requirements file.
795-
# Options specified in requirements file override those
796-
# specified on the command line, since the last option given
797-
# to setup.py is the one that is used.
798-
global_options = list(global_options) + self.global_options
799-
800-
try:
801-
if (
802-
self.legacy_install_reason is not None
803-
and self.legacy_install_reason.emit_before_install
804-
):
805-
self.legacy_install_reason.emit_deprecation(self.name)
806-
success = install_legacy(
807-
global_options=global_options,
808-
root=root,
809-
home=home,
810-
prefix=prefix,
811-
use_user_site=use_user_site,
812-
pycompile=pycompile,
813-
scheme=scheme,
814-
setup_py_path=self.setup_py_path,
815-
isolated=self.isolated,
816-
req_name=self.name,
817-
build_env=self.build_env,
818-
unpacked_source_directory=self.unpacked_source_directory,
819-
req_description=str(self.req),
820-
)
821-
except LegacyInstallFailure as exc:
822-
self.install_succeeded = False
823-
raise exc
824-
except Exception:
825-
self.install_succeeded = True
826-
raise
773+
assert self.is_wheel
774+
assert self.local_file_path
827775

828-
self.install_succeeded = success
829-
830-
if (
831-
success
832-
and self.legacy_install_reason is not None
833-
and self.legacy_install_reason.emit_after_success
834-
):
835-
self.legacy_install_reason.emit_deprecation(self.name)
776+
install_wheel(
777+
self.name,
778+
self.local_file_path,
779+
scheme=scheme,
780+
req_description=str(self.req),
781+
pycompile=pycompile,
782+
warn_script_location=warn_script_location,
783+
direct_url=self.download_info if self.original_link else None,
784+
requested=self.user_supplied,
785+
)
786+
self.install_succeeded = True
836787

837788

838789
def check_invalid_constraint_type(req: InstallRequirement) -> str:

src/pip/_internal/utils/deprecation.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -118,32 +118,3 @@ def deprecated(
118118
raise PipDeprecationWarning(message)
119119

120120
warnings.warn(message, category=PipDeprecationWarning, stacklevel=2)
121-
122-
123-
class LegacyInstallReason:
124-
def __init__(
125-
self,
126-
reason: str,
127-
replacement: Optional[str] = None,
128-
gone_in: Optional[str] = None,
129-
feature_flag: Optional[str] = None,
130-
issue: Optional[int] = None,
131-
emit_after_success: bool = False,
132-
emit_before_install: bool = False,
133-
):
134-
self._reason = reason
135-
self._replacement = replacement
136-
self._gone_in = gone_in
137-
self._feature_flag = feature_flag
138-
self._issue = issue
139-
self.emit_after_success = emit_after_success
140-
self.emit_before_install = emit_before_install
141-
142-
def emit_deprecation(self, name: str) -> None:
143-
deprecated(
144-
reason=self._reason.format(name=name),
145-
replacement=self._replacement,
146-
gone_in=self._gone_in,
147-
feature_flag=self._feature_flag,
148-
issue=self._issue,
149-
)

src/pip/_internal/utils/setuptools_build.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -144,48 +144,3 @@ def make_setuptools_egg_info_args(
144144
args += ["--egg-base", egg_info_dir]
145145

146146
return args
147-
148-
149-
def make_setuptools_install_args(
150-
setup_py_path: str,
151-
*,
152-
global_options: Sequence[str],
153-
record_filename: str,
154-
root: Optional[str],
155-
prefix: Optional[str],
156-
header_dir: Optional[str],
157-
home: Optional[str],
158-
use_user_site: bool,
159-
no_user_config: bool,
160-
pycompile: bool,
161-
) -> List[str]:
162-
assert not (use_user_site and prefix)
163-
assert not (use_user_site and root)
164-
165-
args = make_setuptools_shim_args(
166-
setup_py_path,
167-
global_options=global_options,
168-
no_user_config=no_user_config,
169-
unbuffered_output=True,
170-
)
171-
args += ["install", "--record", record_filename]
172-
args += ["--single-version-externally-managed"]
173-
174-
if root is not None:
175-
args += ["--root", root]
176-
if prefix is not None:
177-
args += ["--prefix", prefix]
178-
if home is not None:
179-
args += ["--home", home]
180-
if use_user_site:
181-
args += ["--user", "--prefix="]
182-
183-
if pycompile:
184-
args += ["--compile"]
185-
else:
186-
args += ["--no-compile"]
187-
188-
if header_dir:
189-
args += ["--install-headers", header_dir]
190-
191-
return args

tests/functional/test_show.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
from pip import __version__
66
from pip._internal.commands.show import search_packages_info
7-
from pip._internal.operations.install.legacy import (
8-
write_installed_files_from_setuptools_record,
9-
)
107
from pip._internal.utils.unpacking import untar_file
118
from tests.lib import PipTestEnvironment, TestData, create_test_package_with_setup
129

0 commit comments

Comments
 (0)