Skip to content

Commit 3d93138

Browse files
committed
Parameterize bdist_wheel and clean args functions
1 parent c451bce commit 3d93138

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

src/pip/_internal/wheel.py

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -957,23 +957,43 @@ def _build_one_inside_env(self, req, output_dir, python_tag=None):
957957
self._clean_one(req)
958958
return None
959959

960-
def _make_setuptools_bdist_wheel_args(self, req):
960+
def _make_setuptools_bdist_wheel_args(
961+
self,
962+
setup_py_path, # type: str
963+
global_options, # type: Sequence[str]
964+
build_options, # type: Sequence[str]
965+
destination_dir, # type: str
966+
python_tag, # type: Optional[str]
967+
):
968+
# type: (...) -> List[str]
961969
# NOTE: Eventually, we'd want to also -S to the flags here, when we're
962970
# isolating. Currently, it breaks Python in virtualenvs, because it
963971
# relies on site.py to find parts of the standard library outside the
964972
# virtualenv.
965-
return make_setuptools_shim_args(
966-
req.setup_py_path,
967-
global_options=self.global_options,
973+
args = make_setuptools_shim_args(
974+
setup_py_path,
975+
global_options=global_options,
968976
unbuffered_output=True
969977
)
978+
args += ["bdist_wheel", "-d", destination_dir]
979+
args += build_options
980+
if python_tag is not None:
981+
args += ["--python-tag", python_tag]
982+
return args
970983

971-
def _make_setuptools_clean_args(self, req):
972-
return make_setuptools_shim_args(
973-
req.setup_py_path,
974-
global_options=self.global_options,
984+
def _make_setuptools_clean_args(
985+
self,
986+
setup_py_path, # type: str
987+
global_options, # type: Sequence[str]
988+
):
989+
# type: (...) -> List[str]
990+
args = make_setuptools_shim_args(
991+
setup_py_path,
992+
global_options=global_options,
975993
unbuffered_output=True
976994
)
995+
args += ["clean", "--all"]
996+
return args
977997

978998
def _build_one_pep517(self, req, tempd, python_tag=None):
979999
"""Build one InstallRequirement using the PEP 517 build process.
@@ -1019,11 +1039,13 @@ def _build_one_legacy(self, req, tempd, python_tag=None):
10191039
10201040
Returns path to wheel if successfully built. Otherwise, returns None.
10211041
"""
1022-
wheel_args = self._make_setuptools_bdist_wheel_args(req)
1023-
wheel_args += ['bdist_wheel', '-d', tempd]
1024-
wheel_args += self.build_options
1025-
if python_tag is not None:
1026-
wheel_args += ["--python-tag", python_tag]
1042+
wheel_args = self._make_setuptools_bdist_wheel_args(
1043+
req.setup_py_path,
1044+
global_options=self.global_options,
1045+
build_options=self.build_options,
1046+
destination_dir=tempd,
1047+
python_tag=python_tag,
1048+
)
10271049

10281050
spin_message = 'Building wheel for %s (setup.py)' % (req.name,)
10291051
with open_spinner(spin_message) as spinner:
@@ -1051,8 +1073,10 @@ def _build_one_legacy(self, req, tempd, python_tag=None):
10511073
return wheel_path
10521074

10531075
def _clean_one(self, req):
1054-
clean_args = self._make_setuptools_clean_args(req)
1055-
clean_args += ['clean', '--all']
1076+
clean_args = self._make_setuptools_clean_args(
1077+
req.setup_py_path,
1078+
global_options=self.global_options,
1079+
)
10561080

10571081
logger.info('Running setup.py clean for %s', req.name)
10581082
try:

0 commit comments

Comments
 (0)