Parent directory isn't available on pip install (e.g. to determine version with setuptools-scm)
tuukkamustonen opened this issue ยท 5 comments
- Pip version:
19.2.3,19.2.3 - Python version:
2.7,3.5.5 - Operating System:
Ubuntu 14.04,Ubuntu 18.04
Description:
When using setuptools-scm in a git sub-directory, version detection mechanism fails.
With GIT_REPO/subdir/requirements.txt:
.
With GIT_REPO/subdir/setup.py:
from setuptools import setup, find_packages
from setuptools_scm import get_version
setup(
name='pastry-auth',
version=get_version(root='..', relative_to=__file__),
)Executing pip install -r requirements.txt in GIT_REPO/subdir, pip copies GIT_REPO/subdir to /tmp/pip-<hash>-build/ and so when setuptools-scm attempts to determine the version of parent directory (root='..' declaration), it then looks up /tmp, which doesn't have the repository information, and fails.
I faced this in pypa/setuptools-scm#138. It prevents setuptools_scm from detecting git version when you hold multiple components in one git repository (in sub-directories), when having . in requirements.txt.
This seems like a reasonable expectation to me.
I don't understand this case. 1 is clearly being executed as pip install -r requirements.txt in the root of the git repository, but 2 does not work as-is and variations on it either don't work or don't lead me to the conclusion that pip is doing something unexpected:
- If we are in the root of the git repository,
pip install -r requirements.txtwill fail becauserequirements.txtis insubdir/- expected behavior - If we are in the root of the git repository, then
pip install -r subdir/requirements.txtwill fail because the.insubdir/requirements.txtis interpreted relative to the cwd, which does not contain thesetup.py- personally I wouldn't expect this behavior, but I don't think it would be easy to change this now - If we are in
subdir/, thenpip install -r requirements.txtwill succeed, but pip copiessubdir/only - it doesn't give any special treatment to the parent directory just because it is a git repository. This is the expected behavior.
Can we get clear instructions to reproduce this issue? @RonnyPfannschmidt, does the context of pypa/setuptools-scm#138 remind you of what this could be about?
I agree, the ticket was confusing and it even had invalid information. Also, it was missing the important fact that setuptools-scm is used for a version detection mechanism. Sorry, I think I was a bit confused back then (hitting multiple issues in an unfamiliar context often leads to that).
I updated the ticket, please check. I don't have tools/know-how to go deep into this, to ensure what files and directories exist in /tmp during the invocation, as pip cleans temp stuff right away. But I think the ticket makes more sense now: pip only copies the current working dir, and so doesn't copy the parent directory, which would be needed to determine the version (by setuptools-scm).
It doesn't really sound like a bug or shortcoming of pip, but would there be a way for setuptools-scm to acquire the version information, nevertheless?
Yea, this is expected behavior. setuptools-scm can't really find the information since it's not got any way to get a reference to the required VCS directories.
I'll roll this issue up with #2195 (i.e. in-place source distribution builds) and close this issue.
This seems like a reasonable expectation to me.
No idea what me 2 years ago was thinking. ๐คทโโ