Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying destdir as empty string leads to no scripts installed #136

Open
dvzrv opened this issue Aug 15, 2022 · 1 comment · May be fixed by #188
Open

Specifying destdir as empty string leads to no scripts installed #136

dvzrv opened this issue Aug 15, 2022 · 1 comment · May be fixed by #188
Labels
component: destinations Related to WheelDestination and friends type: bug A confirmed bug or unintended behavior

Comments

@dvzrv
Copy link

dvzrv commented Aug 15, 2022

Hi! Recently I have been experimenting a bit with build and installer in the context of CI pipelines.

I noticed that if python -m installer --destdir="" <wheel> at least scripts (but maybe also the rest of the wheel contents) are not installed to / but likely somewhere else.
From a user perspective I would assume that providing empty string would behave the same way as not providing --destdir at all (in which case files are properly installed to the root filesystem).

When looking at e.g. how this is handled in a Makefile which allows overriding of the destination using the DESTDIR environment variable we can observe that the following code snippet follows my above assumption:

PREFIX ?= /usr/local

install:
    install -vDm 644 some/file -t "$(DESTDIR)/$(PREFIX)/share/foo/"
@pradyunsg
Copy link
Member

> /Users/pradyunsg/Developer/github/installer/src/installer/destinations.py(145)_path_with_destdir()
-> return os.path.join(self.destdir, rel_path)
(Pdb) locals()
{'self': <installer.destinations.SchemeDictionaryDestination object at 0x107612a90>, 'scheme': 'purelib', 'path': 'installer/__init__.py', 'file': '/Users/pradyunsg/Developer/github/installer/.venv/lib/python3.11/site-packages/installer/__init__.py', 'file_path': PosixPath('/Users/pradyunsg/Developer/github/installer/.venv/lib/python3.11/site-packages/installer/__init__.py'), 'rel_path': PosixPath('Users/pradyunsg/Developer/github/installer/.venv/lib/python3.11/site-packages/installer/__init__.py')}
(Pdb) self.destdir
''

Well, that's hilarious. You're getting os.path.join("", <path-without-anchor>). A PR improving the behaviour around this would be welcome! :)

@pradyunsg pradyunsg added type: bug A confirmed bug or unintended behavior component: destinations Related to WheelDestination and friends labels May 29, 2023
eli-schwartz added a commit to eli-schwartz/installer that referenced this issue May 29, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: destinations Related to WheelDestination and friends type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants