Skip to content

Commit b262aa3

Browse files
committed
Merge pull request #1080 from qwcode/global_build_dir
fixes for #1078
2 parents d158999 + ef4953d commit b262aa3

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

pip/cmdoptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def make_option_group(group, parser):
141141
default=build_prefix,
142142
help='Directory to unpack packages into and build in. '
143143
'The default in a virtualenv is "<venv path>/build". '
144-
'The default for global installs is "<OS temp dir>/pip-build-<username>".')
144+
'The default for global installs is "<OS temp dir>/pip_build_<username>".')
145145

146146
install_options = make_option(
147147
'--install-option',

pip/commands/install.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pip.locations import src_prefix, virtualenv_no_global, distutils_scheme
88
from pip.basecommand import Command
99
from pip.index import PackageFinder
10-
from pip.exceptions import InstallationError, CommandError
10+
from pip.exceptions import InstallationError, CommandError, PreviousBuildDirError
1111
from pip import cmdoptions
1212

1313

@@ -251,6 +251,8 @@ def run(self, options, args):
251251
elif self.bundle:
252252
requirement_set.create_bundle(self.bundle_filename)
253253
logger.notify('Created bundle in %s' % self.bundle_filename)
254+
except PreviousBuildDirError:
255+
return
254256
finally:
255257
# Clean up
256258
if (not options.no_clean) and ((not options.no_install) or options.download_dir):

pip/commands/wheel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pip.basecommand import Command
77
from pip.index import PackageFinder
88
from pip.log import logger
9-
from pip.exceptions import CommandError
9+
from pip.exceptions import CommandError, PreviousBuildDirError
1010
from pip.req import InstallRequirement, RequirementSet, parse_requirements
1111
from pip.util import normalize_path
1212
from pip.wheel import WheelBuilder, wheel_setuptools_support, setuptools_requirement
@@ -150,6 +150,8 @@ def run(self, options, args):
150150
global_options = options.global_options or []
151151
)
152152
wb.build()
153+
except PreviousBuildDirError:
154+
return
153155
finally:
154156
if not options.no_clean:
155157
requirement_set.cleanup_files()

pip/locations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __get_username():
5757

5858
def _get_build_prefix():
5959
""" Returns a safe build_prefix """
60-
path = os.path.join(tempfile.gettempdir(), 'pip-build-%s' %
60+
path = os.path.join(tempfile.gettempdir(), 'pip_build_%s' %
6161
__get_username())
6262
if sys.platform == 'win32':
6363
""" on windows(tested on 7) temp dirs are isolated """

tests/functional/test_install_cleanup.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,15 @@ def test_cleanup_after_egg_info_exception():
131131
build = env.venv_path/'build'
132132
assert not exists(build), "build/ dir still exists: %s" % result.stdout
133133
env.assert_no_temp()
134+
135+
def test_cleanup_prevented_upon_build_dir_exception():
136+
"""
137+
Test no cleanup occurs after a PreviousBuildDirError
138+
"""
139+
env = reset_env()
140+
build = env.venv_path/'build'/'simple'
141+
os.makedirs(build)
142+
write_file("setup.py", "#", dest=build)
143+
result = run_pip('install', '-f', find_links, '--no-index', 'simple', expect_error=True)
144+
assert "pip can't proceed" in result.stdout, result.stdout
145+
assert exists(build)

tests/unit/test_locations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def get_build_dir_location(self):
7878
""" returns a string pointing to the
7979
current build_prefix.
8080
"""
81-
return os.path.join(self.tempdir, 'pip-build-%s' % self.username)
81+
return os.path.join(self.tempdir, 'pip_build_%s' % self.username)
8282

8383
def test_dir_path(self):
8484
""" test the path name for the build_prefix

0 commit comments

Comments
 (0)