Skip to content

Commit 33b0240

Browse files
authored
Rename {setup_py_dir -> unpacked_source_directory} (#7086)
2 parents ea923d9 + c6a2f0a commit 33b0240

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

src/pip/_internal/operations/generate_metadata.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ def _generate_metadata_legacy(install_req):
4141
# egg.
4242
egg_base_option = [] # type: List[str]
4343
if not install_req.editable:
44-
egg_info_dir = os.path.join(install_req.setup_py_dir, 'pip-egg-info')
44+
egg_info_dir = os.path.join(
45+
install_req.unpacked_source_directory, 'pip-egg-info',
46+
)
4547
egg_base_option = ['--egg-base', egg_info_dir]
4648

4749
# setuptools complains if the target directory does not exist.
@@ -50,7 +52,7 @@ def _generate_metadata_legacy(install_req):
5052
with install_req.build_env:
5153
call_subprocess(
5254
base_cmd + ["egg_info"] + egg_base_option,
53-
cwd=install_req.setup_py_dir,
55+
cwd=install_req.unpacked_source_directory,
5456
command_desc='python setup.py egg_info',
5557
)
5658

src/pip/_internal/pyproject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def _is_list_of_str(obj):
2121
)
2222

2323

24-
def make_pyproject_path(setup_py_dir):
24+
def make_pyproject_path(unpacked_source_directory):
2525
# type: (str) -> str
26-
path = os.path.join(setup_py_dir, 'pyproject.toml')
26+
path = os.path.join(unpacked_source_directory, 'pyproject.toml')
2727

2828
# Python2 __file__ should not be unicode
2929
if six.PY2 and isinstance(path, six.text_type):

src/pip/_internal/req/req_install.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def move_wheel_files(
485485

486486
# Things valid for sdists
487487
@property
488-
def setup_py_dir(self):
488+
def unpacked_source_directory(self):
489489
# type: () -> str
490490
return os.path.join(
491491
self.source_dir,
@@ -495,8 +495,7 @@ def setup_py_dir(self):
495495
def setup_py_path(self):
496496
# type: () -> str
497497
assert self.source_dir, "No source dir for %s" % self
498-
499-
setup_py = os.path.join(self.setup_py_dir, 'setup.py')
498+
setup_py = os.path.join(self.unpacked_source_directory, 'setup.py')
500499

501500
# Python2 __file__ should not be unicode
502501
if six.PY2 and isinstance(setup_py, six.text_type):
@@ -508,8 +507,7 @@ def setup_py_path(self):
508507
def pyproject_toml_path(self):
509508
# type: () -> str
510509
assert self.source_dir, "No source dir for %s" % self
511-
512-
return make_pyproject_path(self.setup_py_dir)
510+
return make_pyproject_path(self.unpacked_source_directory)
513511

514512
def load_pyproject_toml(self):
515513
# type: () -> None
@@ -535,7 +533,9 @@ def load_pyproject_toml(self):
535533
requires, backend, check = pyproject_toml_data
536534
self.requirements_to_check = check
537535
self.pyproject_requires = requires
538-
self.pep517_backend = Pep517HookCaller(self.setup_py_dir, backend)
536+
self.pep517_backend = Pep517HookCaller(
537+
self.unpacked_source_directory, backend
538+
)
539539

540540
# Use a custom function to call subprocesses
541541
self.spin_message = ""
@@ -665,7 +665,7 @@ def depth_of_directory(dir_):
665665
base = self.source_dir
666666
filenames = locate_editable_egg_info(base)
667667
else:
668-
base = os.path.join(self.setup_py_dir, 'pip-egg-info')
668+
base = os.path.join(self.unpacked_source_directory, 'pip-egg-info')
669669
filenames = os.listdir(base)
670670

671671
if not filenames:
@@ -770,8 +770,7 @@ def install_editable(
770770
base_cmd +
771771
['develop', '--no-deps'] +
772772
list(install_options),
773-
774-
cwd=self.setup_py_dir,
773+
cwd=self.unpacked_source_directory,
775774
)
776775

777776
self.install_succeeded = True
@@ -883,7 +882,9 @@ def archive(self, build_dir):
883882
archive_path, 'w', zipfile.ZIP_DEFLATED, allowZip64=True,
884883
)
885884
with zip_output:
886-
dir = os.path.normcase(os.path.abspath(self.setup_py_dir))
885+
dir = os.path.normcase(
886+
os.path.abspath(self.unpacked_source_directory)
887+
)
887888
for dirpath, dirnames, filenames in os.walk(dir):
888889
if 'pip-egg-info' in dirnames:
889890
dirnames.remove('pip-egg-info')
@@ -956,7 +957,7 @@ def install(
956957
with self.build_env:
957958
call_subprocess(
958959
install_args + install_options,
959-
cwd=self.setup_py_dir,
960+
cwd=self.unpacked_source_directory,
960961
spinner=spinner,
961962
)
962963

src/pip/_internal/wheel.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,12 +1019,16 @@ def _build_one_legacy(self, req, tempd, python_tag=None):
10191019
wheel_args += ["--python-tag", python_tag]
10201020

10211021
try:
1022-
output = call_subprocess(wheel_args, cwd=req.setup_py_dir,
1023-
spinner=spinner)
1022+
output = call_subprocess(
1023+
wheel_args,
1024+
cwd=req.unpacked_source_directory,
1025+
spinner=spinner,
1026+
)
10241027
except Exception:
10251028
spinner.finish("error")
10261029
logger.error('Failed building wheel for %s', req.name)
10271030
return None
1031+
10281032
names = os.listdir(tempd)
10291033
wheel_path = get_legacy_build_wheel_path(
10301034
names=names,

0 commit comments

Comments
 (0)