Requirements file which contains `-e` with a relative local path, is only installable from a specific directory
See original GitHub issueEnvironment
- 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?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:16 (7 by maintainers)
Top GitHub Comments
@Thiel Yes. That’s what it has become now. 😃
@TBBle for what it’s worth, I like this idea. Sometimes I install multiple requirements files (that aren’t even called
requirements.txt
in some cases), from different directories, so the path should be relative to the file currently being processed.