Skip to content

Requirements file which contains -e with a relative local path, is only installable from a specific directory #6112

@Thiel

Description

@Thiel

Environment

  • pip version: 18.1
  • Python version: 2.7.14
  • OS: Windows (but I don't think it's restricted to a specific platform)

Description
I would like to be able to call pip install -r path/to/requirements.txt from any directory. However usage of --editable/-e with a relative path inside of a requirements.txt assume that the path is relative the current directory I'm currently in, rather than the directory where the file is located.

My specific use case, involve usage of multiple independent requirements.txt in a directory hierarchy where they can reference each other. And seems to exhibit the same issue.

Expected behavior
Expected behavior would be to not require being in a specific directory in order to call pip install -r path/to/requirements.txt when --editable/-e is being used with relative local path.

How to Reproduce

#! /bin/bash

mkdir dir/
echo '-e .' > dir/requirements.txt
cat - > dir/setup.py <<EOF
from distutils.core import setup, Extension
setup(name='foo', version='1.0')
EOF

pip install -r dir/requirements.txt # FAIL

cd dir
pip install -r requirements.txt # PASS

Output

Directory '.' is not installable. File 'setup.py' not found.
Obtaining file:///C:/project/repro_github/pip_change_dir_r/dir (from -r requirements.txt (line 1))
Installing collected packages: foo
  Found existing installation: foo 1.0
    Uninstalling foo-1.0:
      Successfully uninstalled foo-1.0
  Running setup.py develop for foo
Successfully installed foo

Potential solution
I assume that pip is missing a chdir when the requirements is being interpreted. And doing so would fix all mentioned issue.
Would there be a reason that prevent us to do that?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions