requirementslib icon indicating copy to clipboard operation
requirementslib copied to clipboard

Requirementslib fails to resolve dependency with relative path and working directory mismatch

Open PythonCoderAS opened this issue 2 years ago • 3 comments

As discussed in https://github.com/pypa/pipenv/issues/4900, Requirementslib has an issue when the given relative path and the working directory are different. For example, if the working directory is changed to something other than where the python script is executed, but the relative path is relative to where the script was executed, Requirementslib will fail resolving the requirement.

While it might make sense as to why it's impossible to do so, I wish that the error message was worded clearer and not so crypticly.

PythonCoderAS avatar Dec 24 '21 12:12 PythonCoderAS

@PythonCoderAS I am wondering if this change fixes the issue you have been describing or if you are describing something different: https://github.com/sarugaku/requirementslib/pull/319/files

matteius avatar Jun 28 '22 07:06 matteius

@matteius I tried the patch but it did not work. Here is the commands I followed:

virtualenv venv
source venv/bin/activate
pip install pipenv
cd venv/lib/python3.10/site-packages/pipenv/vendor/requirementslib
patch -p1 <<< `curl -s https://github.com/sarugaku/requirementslib/commit/c1678de7661f2a6fe043e100849ca056edd941d6.diff | sed "s/src\/requirementslib\/models/models/g"`
cd "$OLDPWD"
deactivate
source venv/bin/activate # Recognize new pipenv in PATH
pipenv install
git clone https://github.com/sphinx-doc/sphinx.git
cd sphinx
pipenv install . # Errors here

PythonCoderAS avatar Jun 28 '22 12:06 PythonCoderAS

Thanks for this example @PythonCoderAS -- and if you go up a directory and do it with pipenv install sphinx/ works just fine, so the dot is causing an issue for a regex somewhere it seems. Thanks for checking that other patch which seems to solve a different issue I was checking on. Will take some more investigating to figure out where to patch this in requirementslib.

matteius avatar Jun 28 '22 14:06 matteius