Rename InstallRequirement.{build_location -> ensure_build_location} (#7021)

Merge pull request #7021 from pradyunsg/refactor/rename-build-location
This commit is contained in:
Pradyun Gedam 2019-09-17 18:30:08 +05:30 committed by GitHub
commit c3e6329039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -322,7 +322,7 @@ class InstallRequirement(object):
s += '->' + comes_from
return s
def build_location(self, build_dir):
def ensure_build_location(self, build_dir):
# type: (str) -> str
assert build_dir is not None
if self._temp_build_dir.path is not None:
@ -370,7 +370,7 @@ class InstallRequirement(object):
old_location = self._temp_build_dir.path
self._temp_build_dir.path = None
new_location = self.build_location(self._ideal_build_dir)
new_location = self.ensure_build_location(self._ideal_build_dir)
if os.path.exists(new_location):
raise InstallationError(
'A package already exists in %s; please remove it to continue'
@ -763,7 +763,7 @@ class InstallRequirement(object):
:return: self.source_dir
"""
if self.source_dir is None:
self.source_dir = self.build_location(parent_dir)
self.source_dir = self.ensure_build_location(parent_dir)
# For editable installations
def install_editable(

View File

@ -1146,7 +1146,7 @@ class WheelBuilder(object):
req.remove_temporary_source()
# set the build directory again - name is known from
# the work prepare_files did.
req.source_dir = req.build_location(
req.source_dir = req.ensure_build_location(
self.preparer.build_dir
)
# Update the link for this.

View File

@ -20,7 +20,7 @@ class TestInstallRequirementBuildDirectory(object):
# Make sure we're handling it correctly with real path.
requirement = InstallRequirement(None, None)
tmp_dir = tempfile.mkdtemp('-build', 'pip-')
tmp_build_dir = requirement.build_location(tmp_dir)
tmp_build_dir = requirement.ensure_build_location(tmp_dir)
assert (
os.path.dirname(tmp_build_dir) ==
os.path.realpath(os.path.dirname(tmp_dir))