Skip to content

Commit 046111c

Browse files
committed
Make in-tree-build the default
Add an out-of-tree-build feature flag to ease the transition.
1 parent 605d68e commit 046111c

File tree

6 files changed

+39
-30
lines changed

6 files changed

+39
-30
lines changed

docs/html/cli/pip_install.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -490,18 +490,20 @@ You can install local projects by specifying the project path to pip:
490490
491491
py -m pip install path/to/SomeProject
492492
493-
During regular installation, pip will copy the entire project directory to a
494-
temporary location and install from there. The exception is that pip will
495-
exclude .tox and .nox directories present in the top level of the project from
496-
being copied. This approach is the cause of several performance and correctness
497-
issues, so it is planned that pip 21.3 will change to install directly from the
498-
local project directory. Depending on the build backend used by the project,
499-
this may generate secondary build artifacts in the project directory, such as
500-
the ``.egg-info`` and ``build`` directories in the case of the setuptools
501-
backend.
502-
503-
To opt in to the future behavior, specify the ``--use-feature=in-tree-build``
504-
option in pip's command line.
493+
.. note::
494+
495+
Depending on the build backend used by the project, this may generate
496+
secondary build artifacts in the project directory, such as the
497+
``.egg-info`` and ``build`` directories in the case of the setuptools
498+
backend.
499+
500+
Pip has a legacy behaviour that copies the entire project directory to a
501+
temporary location and installs from there. This approach was the cause of
502+
several performance and correctness issues, so it is now disabled by
503+
default, and it is planned that pip 22.1 will remove it.
504+
505+
To opt in to the legacy behavior, specify the
506+
``--use-deprecated=out-of-tree-build`` option in pip's command line.
505507

506508

507509
.. _`editable-installs`:

news/10495.removal.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
In-tree builds are now the default. ``--use-feature=in-tree-build`` is now
2+
ignored. ``--use-deprecated=out-of-tree-build`` may be used temporarily to ease
3+
the transition.

src/pip/_internal/cli/cmdoptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ def check_list_path_option(options: Values) -> None:
961961
metavar="feature",
962962
action="append",
963963
default=[],
964-
choices=["legacy-resolver"],
964+
choices=["legacy-resolver", "out-of-tree-build"],
965965
help=("Enable deprecated functionality, that will be removed in the future."),
966966
)
967967

src/pip/_internal/cli/req_command.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from pip._internal.req.req_tracker import RequirementTracker
3535
from pip._internal.resolution.base import BaseResolver
3636
from pip._internal.self_outdated_check import pip_self_version_check
37+
from pip._internal.utils.deprecation import deprecated
3738
from pip._internal.utils.temp_dir import (
3839
TempDirectory,
3940
TempDirectoryTypeRegistry,
@@ -260,6 +261,20 @@ def make_requirement_preparer(
260261
"fast-deps has no effect when used with the legacy resolver."
261262
)
262263

264+
in_tree_build = "out-of-tree-build" not in options.deprecated_features_enabled
265+
if "in-tree-build" in options.features_enabled:
266+
deprecated(
267+
reason="In-tree builds are now the default.",
268+
replacement="to remove the --use-feature=in-tree-build flag",
269+
gone_in="22.1",
270+
)
271+
if "out-of-tree-build" in options.deprecated_features_enabled:
272+
deprecated(
273+
reason="Out-of-tree builds are deprecated.",
274+
replacement=None,
275+
gone_in="22.1",
276+
)
277+
263278
return RequirementPreparer(
264279
build_dir=temp_build_dir_path,
265280
src_dir=options.src_dir,
@@ -272,7 +287,7 @@ def make_requirement_preparer(
272287
require_hashes=options.require_hashes,
273288
use_user_site=use_user_site,
274289
lazy_wheel=lazy_wheel,
275-
in_tree_build="in-tree-build" in options.features_enabled,
290+
in_tree_build=in_tree_build,
276291
)
277292

278293
@classmethod

src/pip/_internal/operations/prepare.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from pip._internal.network.session import PipSession
3636
from pip._internal.req.req_install import InstallRequirement
3737
from pip._internal.req.req_tracker import RequirementTracker
38-
from pip._internal.utils.deprecation import deprecated
3938
from pip._internal.utils.filesystem import copy2_fixed
4039
from pip._internal.utils.hashes import Hashes, MissingHashes
4140
from pip._internal.utils.logging import indent_log
@@ -197,19 +196,9 @@ def unpack_url(
197196
#
198197
# As further cleanup, _copy_source_tree and accompanying tests can
199198
# be removed.
199+
#
200+
# TODO when use-deprecated=out-of-tree-build is removed
200201
if link.is_existing_dir():
201-
deprecated(
202-
reason=(
203-
"pip copied the source tree into a temporary directory "
204-
"before building it. This is changing so that packages "
205-
"are built in-place "
206-
'within the original source tree ("in-tree build").'
207-
),
208-
replacement=None,
209-
gone_in="21.3",
210-
feature_flag="in-tree-build",
211-
issue=7555,
212-
)
213202
if os.path.isdir(location):
214203
rmtree(location)
215204
_copy_source_tree(link.file_path, location)

tests/functional/test_install.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ def test_install_from_local_directory_with_symlinks_to_directories(script, data)
587587
Test installing from a local directory containing symlinks to directories.
588588
"""
589589
to_install = data.packages.joinpath("symlinks")
590-
result = script.pip("install", to_install)
590+
result = script.pip("install", "--use-deprecated=out-of-tree-build", to_install)
591591
pkg_folder = script.site_packages / "symlinks"
592592
dist_info_folder = script.site_packages / "symlinks-0.1.dev0.dist-info"
593593
result.did_create(pkg_folder)
@@ -597,10 +597,10 @@ def test_install_from_local_directory_with_symlinks_to_directories(script, data)
597597
@pytest.mark.usefixtures("with_wheel")
598598
def test_install_from_local_directory_with_in_tree_build(script, data):
599599
"""
600-
Test installing from a local directory with --use-feature=in-tree-build.
600+
Test installing from a local directory with default in tree build.
601601
"""
602602
to_install = data.packages.joinpath("FSPkg")
603-
args = ["install", "--use-feature=in-tree-build", to_install]
603+
args = ["install", to_install]
604604

605605
in_tree_build_dir = to_install / "build"
606606
assert not in_tree_build_dir.exists()

0 commit comments

Comments
 (0)