Skip to content

Commit d23668a

Browse files
committed
Move mac arch calculation to separate function
1 parent a5948e6 commit d23668a

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/pip/_internal/pep425tags.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,25 @@ def get_all_minor_versions_as_strings(version_info):
261261
return versions
262262

263263

264+
def _mac_platforms(arch):
265+
# type: (str) -> List[str]
266+
match = _osx_arch_pat.match(arch)
267+
if match:
268+
name, major, minor, actual_arch = match.groups()
269+
mac_version = (int(major), int(minor))
270+
mac_arches = list(mac_platforms(mac_version, actual_arch))
271+
arches = [
272+
# Technically a user could've passed something only
273+
# starting with 'macosx', not necessarily macosx_.
274+
'{}_{}'.format(name, arch[len('macosx_'):])
275+
for arch in mac_arches
276+
]
277+
else:
278+
# arch pattern didn't match (?!)
279+
arches = [arch]
280+
return arches
281+
282+
264283
def get_supported(
265284
version=None, # type: Optional[str]
266285
platform=None, # type: Optional[str]
@@ -311,20 +330,7 @@ def get_supported(
311330
arch = platform or get_platform()
312331
arch_prefix, arch_sep, arch_suffix = arch.partition('_')
313332
if arch.startswith('macosx'):
314-
match = _osx_arch_pat.match(arch)
315-
if match:
316-
name, major, minor, actual_arch = match.groups()
317-
mac_version = (int(major), int(minor))
318-
mac_arches = list(mac_platforms(mac_version, actual_arch))
319-
arches = [
320-
# Technically a user could've passed something only
321-
# starting with 'macosx', not necessarily macosx_.
322-
'{}_{}'.format(name, arch[len('macosx_'):])
323-
for arch in mac_arches
324-
]
325-
else:
326-
# arch pattern didn't match (?!)
327-
arches = [arch]
333+
arches = _mac_platforms(arch)
328334
elif arch_prefix == 'manylinux2014':
329335
arches = [arch]
330336
# manylinux1/manylinux2010 wheels run on most manylinux2014 systems

0 commit comments

Comments
 (0)