Pip: Parent directory isn't available on pip install (e.g. to determine version with setuptools-scm)

Created on 13 Dec 2016  路  5Comments  路  Source: pypa/pip

  • 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 https://github.com/pypa/setuptools_scm/issues/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.

vcs auto-locked needs repro

Most helpful comment

This seems like a reasonable expectation to me.

No idea what me 2 years ago was thinking. 馃し鈥嶁檪

All 5 comments

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:

  1. If we are in the root of the git repository, pip install -r requirements.txt will fail because requirements.txt is in subdir/ - expected behavior
  2. If we are in the root of the git repository, then pip install -r subdir/requirements.txt will fail because the . in subdir/requirements.txt is interpreted relative to the cwd, which does not contain the setup.py - personally I wouldn't expect this behavior, but I don't think it would be easy to change this now
  3. If we are in subdir/, then pip install -r requirements.txt will succeed, but pip copies subdir/ 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. 馃し鈥嶁檪

Was this page helpful?
0 / 5 - 0 ratings