From 61e15f8eb0e03420e8ec543bebf85bd0bbbadb1c Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Mon, 29 May 2023 17:48:32 -0400 Subject: [PATCH] Treat an empty destination the same as an unspecified one With a command line such as: ``` python -m installer --destdir="$DESTDIR" dist/*.whl ``` The destdir may not be "set" but is always passed. When relocating paths relative to the destination directory, the anchor is chopped off, resulting in paths that are relative to the process-wide current working directory, and are installed relative to there. Avoid doing any relocations against an empty destdir. Fixes #136 --- src/installer/destinations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/installer/destinations.py b/src/installer/destinations.py index a3c1967a..915acb6c 100644 --- a/src/installer/destinations.py +++ b/src/installer/destinations.py @@ -138,7 +138,7 @@ def __init__( def _path_with_destdir(self, scheme: Scheme, path: str) -> str: file = os.path.join(self.scheme_dict[scheme], path) - if self.destdir is not None: + if self.destdir: file_path = Path(file) rel_path = file_path.relative_to(file_path.anchor) return os.path.join(self.destdir, rel_path)