Skip to content

Commit

Permalink
Treat an empty destination the same as an unspecified one
Browse files Browse the repository at this point in the history
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 pypa#136
  • Loading branch information
eli-schwartz committed May 29, 2023
1 parent 5f281b8 commit 61e15f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/installer/destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 61e15f8

Please sign in to comment.