question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
pradyunsgcommented, Feb 5, 2019

@Thiel Yes. That’s what it has become now. 😃

1reaction
DavidAntliffcommented, Oct 10, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

use a relative path in requirements.txt to install a tar.gz file with ...
This path is not relative to the requirements.txt file, but rather to the current working directory. Therefore it is necessary to navigate ...
Read more >
Requirements File Format - pip documentation v22.3.1
Requirements files serve as a list of items to be installed by pip, when using pip install. Files that use this format are...
Read more >
Making a Python Package
Save it as setup.py outside the capitalize package dir. Install it in “editable” mode: $ pip install -e ./ Obtaining file:///Users/chris ...
Read more >
NVIDIA CUDA Installation Guide for Linux
These cores have shared resources including a register file and a shared memory. ... The CUDA Development Tools are only supported on some...
Read more >
Python Dependencies via Pip - Heroku Dev Center
Any requirements that install locally with the following command will ... specify the relative path to the directory containing setup.py :
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found