Skip to content

Commit 7dbf383

Browse files
committed
MAINT: simplify _map_from_scheme_map()
1 parent 7348228 commit 7dbf383

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

mesonpy/__init__.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -397,20 +397,12 @@ def _is_native(self, file: Union[str, pathlib.Path]) -> bool:
397397
return False
398398

399399
def _map_from_scheme_map(self, destination: str) -> Optional[Tuple[str, pathlib.Path]]:
400-
"""Extracts scheme and relative destination from Meson paths.
401-
402-
Meson destination path -> (wheel scheme, subpath inside the scheme)
403-
Eg. {bindir}/foo/bar -> (scripts, foo/bar)
404-
"""
405-
for scheme, placeholder in [
406-
(scheme, placeholder)
407-
for scheme, placeholders in self._SCHEME_MAP.items()
408-
for placeholder in placeholders
409-
]: # scheme name, scheme path (see self._SCHEME_MAP)
410-
if destination.startswith(placeholder):
411-
relative_destination = pathlib.Path(destination).relative_to(placeholder)
412-
return scheme, relative_destination
413-
return None # no match was found
400+
"""Extracts scheme and relative destination from installation paths."""
401+
parts = pathlib.Path(destination).parts
402+
for scheme, placeholders in self._SCHEME_MAP.items():
403+
if parts[0] in placeholders:
404+
return scheme, pathlib.Path(*parts[1:])
405+
return None
414406

415407
def _map_to_wheel(
416408
self,

0 commit comments

Comments
 (0)