Skip to content

Commit 9a5441c

Browse files
authored
Merge pull request #9049 from pfmoore/remove_build_dir
2 parents f2852cd + 52e1c9a commit 9a5441c

File tree

10 files changed

+17
-122
lines changed

10 files changed

+17
-122
lines changed

news/9049.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove the ``--build-dir`` option, as per the deprecation.

src/pip/_internal/cli/base_command.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,6 @@ def _main(self, args):
197197
)
198198
options.cache_dir = None
199199

200-
if getattr(options, "build_dir", None):
201-
deprecated(
202-
reason=(
203-
"The -b/--build/--build-dir/--build-directory "
204-
"option is deprecated."
205-
),
206-
replacement=(
207-
"use the TMPDIR/TEMP/TMP environment variable, "
208-
"possibly combined with --no-clean"
209-
),
210-
gone_in="20.3",
211-
issue=8333,
212-
)
213-
214200
if 'resolver' in options.unstable_features:
215201
logger.critical(
216202
"--unstable-feature=resolver is no longer supported, and "

src/pip/_internal/cli/cmdoptions.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -685,29 +685,6 @@ def _handle_no_cache_dir(option, opt, value, parser):
685685
) # type: Callable[..., Option]
686686

687687

688-
def _handle_build_dir(option, opt, value, parser):
689-
# type: (Option, str, str, OptionParser) -> None
690-
if value:
691-
value = os.path.abspath(value)
692-
setattr(parser.values, option.dest, value)
693-
694-
695-
build_dir = partial(
696-
PipOption,
697-
'-b', '--build', '--build-dir', '--build-directory',
698-
dest='build_dir',
699-
type='path',
700-
metavar='dir',
701-
action='callback',
702-
callback=_handle_build_dir,
703-
help='(DEPRECATED) '
704-
'Directory to unpack packages into and build in. Note that '
705-
'an initial build still takes place in a temporary directory. '
706-
'The location of temporary directories can be controlled by setting '
707-
'the TMPDIR environment variable (TEMP on Windows) appropriately. '
708-
'When passed, build directories are not cleaned in case of failures.'
709-
) # type: Callable[..., Option]
710-
711688
ignore_requires_python = partial(
712689
Option,
713690
'--ignore-requires-python',

src/pip/_internal/commands/download.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def add_options(self):
4343
# type: () -> None
4444
self.cmd_opts.add_option(cmdoptions.constraints())
4545
self.cmd_opts.add_option(cmdoptions.requirements())
46-
self.cmd_opts.add_option(cmdoptions.build_dir())
4746
self.cmd_opts.add_option(cmdoptions.no_deps())
4847
self.cmd_opts.add_option(cmdoptions.global_options())
4948
self.cmd_opts.add_option(cmdoptions.no_binary())
@@ -97,13 +96,11 @@ def run(self, options, args):
9796
session=session,
9897
target_python=target_python,
9998
)
100-
build_delete = (not (options.no_clean or options.build_dir))
10199

102100
req_tracker = self.enter_context(get_requirement_tracker())
103101

104102
directory = TempDirectory(
105-
options.build_dir,
106-
delete=build_delete,
103+
delete=not options.no_clean,
107104
kind="download",
108105
globally_managed=True,
109106
)

src/pip/_internal/commands/install.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ def add_options(self):
129129
help="Installation prefix where lib, bin and other top-level "
130130
"folders are placed")
131131

132-
self.cmd_opts.add_option(cmdoptions.build_dir())
133-
134132
self.cmd_opts.add_option(cmdoptions.src())
135133

136134
self.cmd_opts.add_option(
@@ -277,14 +275,12 @@ def run(self, options, args):
277275
target_python=target_python,
278276
ignore_requires_python=options.ignore_requires_python,
279277
)
280-
build_delete = (not (options.no_clean or options.build_dir))
281278
wheel_cache = WheelCache(options.cache_dir, options.format_control)
282279

283280
req_tracker = self.enter_context(get_requirement_tracker())
284281

285282
directory = TempDirectory(
286-
options.build_dir,
287-
delete=build_delete,
283+
delete=not options.no_clean,
288284
kind="install",
289285
globally_managed=True,
290286
)

src/pip/_internal/commands/wheel.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def add_options(self):
7878
self.cmd_opts.add_option(cmdoptions.src())
7979
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
8080
self.cmd_opts.add_option(cmdoptions.no_deps())
81-
self.cmd_opts.add_option(cmdoptions.build_dir())
8281
self.cmd_opts.add_option(cmdoptions.progress_bar())
8382

8483
self.cmd_opts.add_option(
@@ -115,7 +114,6 @@ def run(self, options, args):
115114
session = self.get_default_session(options)
116115

117116
finder = self._build_package_finder(options, session)
118-
build_delete = (not (options.no_clean or options.build_dir))
119117
wheel_cache = WheelCache(options.cache_dir, options.format_control)
120118

121119
options.wheel_dir = normalize_path(options.wheel_dir)
@@ -124,8 +122,7 @@ def run(self, options, args):
124122
req_tracker = self.enter_context(get_requirement_tracker())
125123

126124
directory = TempDirectory(
127-
options.build_dir,
128-
delete=build_delete,
125+
delete=not options.no_clean,
129126
kind="wheel",
130127
globally_managed=True,
131128
)

src/pip/_internal/req/req_install.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ def ensure_build_location(self, build_dir, autodelete, parallel_builds):
358358

359359
return self._temp_build_dir.path
360360

361+
# This is the only remaining place where we manually determine the path
362+
# for the temporary directory. It is only needed for editables where
363+
# it is the value of the --src option.
364+
361365
# When parallel builds are enabled, add a UUID to the build directory
362366
# name so multiple builds do not interfere with each other.
363367
dir_name = canonicalize_name(self.name)

src/pip/_internal/utils/temp_dir.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ def __init__(
134134
# tempdir_registry says.
135135
delete = None
136136

137+
# The only time we specify path is in for editables where it
138+
# is the value of the --src option.
137139
if path is None:
138140
path = self._create(kind)
139141

tests/functional/test_install_cleanup.py

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import os
21
from os.path import exists
32

43
import pytest
54

6-
from pip._internal.cli.status_codes import PREVIOUS_BUILD_DIR_ERROR
7-
85

96
@pytest.mark.network
7+
@pytest.mark.xfail(
8+
reason="The --build option was removed"
9+
)
1010
def test_no_clean_option_blocks_cleaning_after_install(script, data):
1111
"""
1212
Test --no-clean option blocks cleaning after install
@@ -23,38 +23,6 @@ def test_no_clean_option_blocks_cleaning_after_install(script, data):
2323
assert exists(build)
2424

2525

26-
@pytest.mark.network
27-
def test_cleanup_prevented_upon_build_dir_exception(
28-
script,
29-
data,
30-
use_new_resolver,
31-
):
32-
"""
33-
Test no cleanup occurs after a PreviousBuildDirError
34-
"""
35-
build = script.venv_path / 'build'
36-
build_simple = build / 'simple'
37-
os.makedirs(build_simple)
38-
build_simple.joinpath("setup.py").write_text("#")
39-
result = script.pip(
40-
'install', '-f', data.find_links, '--no-index', 'simple',
41-
'--build', build,
42-
expect_error=(not use_new_resolver),
43-
expect_temp=(not use_new_resolver),
44-
expect_stderr=True,
45-
)
46-
47-
assert (
48-
"The -b/--build/--build-dir/--build-directory "
49-
"option is deprecated."
50-
) in result.stderr
51-
52-
if not use_new_resolver:
53-
assert result.returncode == PREVIOUS_BUILD_DIR_ERROR, str(result)
54-
assert "pip can't proceed" in result.stderr, str(result)
55-
assert exists(build_simple), str(result)
56-
57-
5826
@pytest.mark.network
5927
def test_pep517_no_legacy_cleanup(script, data, with_wheel):
6028
"""Test a PEP 517 failed build does not attempt a legacy cleanup"""

tests/functional/test_wheel.py

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88

9-
from pip._internal.cli.status_codes import ERROR, PREVIOUS_BUILD_DIR_ERROR
9+
from pip._internal.cli.status_codes import ERROR
1010
from tests.lib import pyversion # noqa: F401
1111

1212

@@ -187,6 +187,9 @@ def test_pip_wheel_fail(script, data):
187187
assert result.returncode != 0
188188

189189

190+
@pytest.mark.xfail(
191+
reason="The --build option was removed"
192+
)
190193
def test_no_clean_option_blocks_cleaning_after_wheel(
191194
script,
192195
data,
@@ -229,42 +232,6 @@ def test_pip_wheel_source_deps(script, data):
229232
assert "Successfully built source" in result.stdout, result.stdout
230233

231234

232-
def test_pip_wheel_fail_cause_of_previous_build_dir(
233-
script,
234-
data,
235-
use_new_resolver,
236-
):
237-
"""
238-
Test when 'pip wheel' tries to install a package that has a previous build
239-
directory
240-
"""
241-
242-
# Given that I have a previous build dir of the `simple` package
243-
build = script.venv_path / 'build' / 'simple'
244-
os.makedirs(build)
245-
build.joinpath('setup.py').write_text('#')
246-
247-
# When I call pip trying to install things again
248-
result = script.pip(
249-
'wheel', '--no-index',
250-
'--find-links={data.find_links}'.format(**locals()),
251-
'--build', script.venv_path / 'build',
252-
'simple==3.0',
253-
expect_error=(not use_new_resolver),
254-
expect_temp=(not use_new_resolver),
255-
expect_stderr=True,
256-
)
257-
258-
assert (
259-
"The -b/--build/--build-dir/--build-directory "
260-
"option is deprecated."
261-
) in result.stderr
262-
263-
# Then I see that the error code is the right one
264-
if not use_new_resolver:
265-
assert result.returncode == PREVIOUS_BUILD_DIR_ERROR, result
266-
267-
268235
def test_wheel_package_with_latin1_setup(script, data):
269236
"""Create a wheel from a package with latin-1 encoded setup.py."""
270237

0 commit comments

Comments
 (0)