Skip to content

Commit 3577f43

Browse files
committed
ENH: simplify
1 parent 6138f8d commit 3577f43

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
@@ -421,20 +421,12 @@ def _warn_unsure_platlib(self, origin: pathlib.Path, destination: pathlib.Path)
421421
)
422422

423423
def _map_from_scheme_map(self, destination: str) -> Optional[Tuple[str, pathlib.Path]]:
424-
"""Extracts scheme and relative destination from Meson paths.
425-
426-
Meson destination path -> (wheel scheme, subpath inside the scheme)
427-
Eg. {bindir}/foo/bar -> (scripts, foo/bar)
428-
"""
429-
for scheme, placeholder in [
430-
(scheme, placeholder)
431-
for scheme, placeholders in self._SCHEME_MAP.items()
432-
for placeholder in placeholders
433-
]: # scheme name, scheme path (see self._SCHEME_MAP)
434-
if destination.startswith(placeholder):
435-
relative_destination = pathlib.Path(destination).relative_to(placeholder)
436-
return scheme, relative_destination
437-
return None # no match was found
424+
"""Extracts scheme and relative destination from installation paths."""
425+
parts = pathlib.Path(destination).parts
426+
for scheme, placeholders in self._SCHEME_MAP.items():
427+
if parts[0] in placeholders:
428+
return scheme, pathlib.Path(os.path.join(*parts[1:]))
429+
return None
438430

439431
def _map_to_wheel(
440432
self,

0 commit comments

Comments
 (0)