Skip to content

Stop falling back to setup.py install by default #11013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/pip/_internal/cli/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ def check_list_path_option(options: Values) -> None:
"out-of-tree-build",
"backtrack-on-build-failures",
"html5lib",
"legacy-setup-py-install",
],
help=("Enable deprecated functionality, that will be removed in the future."),
)
Expand Down
37 changes: 20 additions & 17 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ def run(self, options: Values, args: List[str]) -> int:
raise CommandError("Can not combine '--user' and '--target'")

cmdoptions.check_install_build_global(options)
should_fallback_to_legacy_install = (
"legacy-setup-py-install" in options.deprecated_features_enabled
)
upgrade_strategy = "to-satisfy-only"
if options.upgrade:
upgrade_strategy = options.upgrade_strategy
Expand Down Expand Up @@ -366,25 +369,25 @@ def run(self, options: Values, args: List[str]) -> int:
global_options=[],
)

# If we're using PEP 517, we cannot do a legacy setup.py install
# so we fail here.
pep517_build_failure_names: List[str] = [
r.name for r in build_failures if r.use_pep517 # type: ignore
]
if pep517_build_failure_names:
raise InstallationError(
"Could not build wheels for {}, which is required to "
"install pyproject.toml-based projects".format(
", ".join(pep517_build_failure_names)
if build_failures:
if not should_fallback_to_legacy_install:
raise InstallationError(
"Could not build wheels for {}, which is required to "
"install pyproject.toml-based projects".format(
", ".join([r.name for r in build_failures]) # type: ignore
)
)
)

# For now, we just warn about failures building legacy
# requirements, as we'll fall through to a setup.py install for
# those.
for r in build_failures:
if not r.use_pep517:
r.legacy_install_reason = 8368
pep517_build_failures = [r for r in build_failures if r.use_pep517]
if pep517_build_failures:
raise InstallationError(
"Could not build wheels for {}, which is required to "
"install pyproject.toml-based projects".format(
", ".join(
[r.name for r in pep517_build_failures] # type: ignore
)
)
)

to_install = resolver.get_installation_order(requirement_set)

Expand Down
22 changes: 8 additions & 14 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def __init__(
self.constraint = constraint
self.editable = editable
self.permit_editable_wheels = permit_editable_wheels
self.legacy_install_reason: Optional[int] = None

# source_dir is the local directory where the linked requirement is
# located, or unpacked. In case unpacking is needed, creating and
Expand Down Expand Up @@ -788,6 +787,14 @@ def install(
global_options = list(global_options) + self.global_options
install_options = list(install_options) + self.install_options

deprecated(
reason=(
"Using 'setup.py install' for performing a package installation "
"is deprecated."
),
replacement="correctly building a wheel for this package",
gone_in="23.0",
)
try:
success = install_legacy(
install_options=install_options,
Expand All @@ -814,19 +821,6 @@ def install(

self.install_succeeded = success

if success and self.legacy_install_reason == 8368:
deprecated(
reason=(
"{} was installed using the legacy 'setup.py install' "
"method, because a wheel could not be built for it.".format(
self.name
)
),
replacement="to fix the wheel build issue reported above",
gone_in=None,
issue=8368,
)


def check_invalid_constraint_type(req: InstallRequirement) -> str:

Expand Down