Skip to content

Commit 4c9baee

Browse files
committed
Separate functions for getting custom and native platforms
We can drop the "else" in the native platforms case because platform would have had to be `None` to get in this function.
1 parent 1825062 commit 4c9baee

File tree

1 file changed

+44
-16
lines changed

1 file changed

+44
-16
lines changed

src/pip/_internal/pep425tags.py

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,47 @@ def _custom_manylinux_platforms(arch):
306306
return arches
307307

308308

309+
def _get_custom_platforms(arch):
310+
# type: (str) -> List[str]
311+
arch_prefix, arch_sep, arch_suffix = arch.partition('_')
312+
if arch.startswith('macosx'):
313+
arches = _mac_platforms(arch)
314+
elif arch_prefix in ['manylinux2014', 'manylinux2010']:
315+
arches = _custom_manylinux_platforms(arch)
316+
elif arch is None:
317+
arches = []
318+
if is_manylinux2014_compatible():
319+
arches.append('manylinux2014' + arch_sep + arch_suffix)
320+
if is_manylinux2010_compatible():
321+
arches.append('manylinux2010' + arch_sep + arch_suffix)
322+
if is_manylinux1_compatible():
323+
arches.append('manylinux1' + arch_sep + arch_suffix)
324+
arches.append(arch)
325+
else:
326+
arches = [arch]
327+
return arches
328+
329+
330+
def _get_platforms():
331+
# type: () -> List[str]
332+
arch = get_platform()
333+
arch_prefix, arch_sep, arch_suffix = arch.partition('_')
334+
if arch.startswith('macosx'):
335+
arches = _mac_platforms(arch)
336+
elif arch_prefix in ['manylinux2014', 'manylinux2010']:
337+
arches = _custom_manylinux_platforms(arch)
338+
else:
339+
arches = []
340+
if is_manylinux2014_compatible():
341+
arches.append('manylinux2014' + arch_sep + arch_suffix)
342+
if is_manylinux2010_compatible():
343+
arches.append('manylinux2010' + arch_sep + arch_suffix)
344+
if is_manylinux1_compatible():
345+
arches.append('manylinux1' + arch_sep + arch_suffix)
346+
arches.append(arch)
347+
return arches
348+
349+
309350
def get_supported(
310351
version=None, # type: Optional[str]
311352
platform=None, # type: Optional[str]
@@ -353,23 +394,10 @@ def get_supported(
353394

354395
abis.append('none')
355396

356-
arch = platform or get_platform()
357-
arch_prefix, arch_sep, arch_suffix = arch.partition('_')
358-
if arch.startswith('macosx'):
359-
arches = _mac_platforms(arch)
360-
elif arch_prefix in ['manylinux2014', 'manylinux2010']:
361-
arches = _custom_manylinux_platforms(arch)
362-
elif platform is None:
363-
arches = []
364-
if is_manylinux2014_compatible():
365-
arches.append('manylinux2014' + arch_sep + arch_suffix)
366-
if is_manylinux2010_compatible():
367-
arches.append('manylinux2010' + arch_sep + arch_suffix)
368-
if is_manylinux1_compatible():
369-
arches.append('manylinux1' + arch_sep + arch_suffix)
370-
arches.append(arch)
397+
if platform:
398+
arches = _get_custom_platforms(platform)
371399
else:
372-
arches = [arch]
400+
arches = _get_platforms()
373401

374402
# Current version, current API (built specifically for our Python):
375403
for abi in abis:

0 commit comments

Comments
 (0)