pip-check-reqs icon indicating copy to clipboard operation
pip-check-reqs copied to clipboard

extra-reqs fails with venv -- accidentally concatenates duplicate paths resulting in mistakes

Open theahura opened this issue 3 years ago • 3 comments

Running pip-extra-reqs inside a virtual env resulted in every package being displayed as extraneous. I dug around a bit in the code and found that this if statement is never being triggered, because info.filename has a path like:

/home/amol/code/env/lib/python3.8/site-packages/pymongo/results.py

while installed_files have paths like:

/home/amol/code/env/lib/python3.8/site-packages/env/lib/python3.8/site-packages/pymongo/results.py

note that the latter has the env path duplicated. This is happening because there is an os.path.join here. That join operates on two variables, package_location and package_file. The former looks like this:

/home/amol/code/env/lib/python3.8/site-packages

and the latter like this:

env/lib/python3.8/site-packages/pymongo/results.py

So of course the path concatenation doubles up the env.

I wasn't able to dig deeper than this, but it seems like a pretty straightforward bug.

File structure:

requirements.txt
src/
  server.py
env/
  lib/
    python3.8/
      site-packages/

theahura avatar Oct 30 '21 17:10 theahura

Sorry for the long wait. Could you please show a minimal example of how you get to this issue? It's probably just me being thick, but I cannot reproduce it.

MrMino avatar Mar 17 '22 12:03 MrMino

Could you please show a minimal example of how you get to this issue?

I meant this in terms of creating a virtualenv. I cannot reproduce this using either mktmpenv from virtualenvwrapper nor the standard virtualenv command. I also poked in the internals, added some prints, and I'm unable to trigger the path catenation issue you've shown.

Also, do you remember which pip version you had installed when you encountered this bug?

MrMino avatar Mar 19 '22 10:03 MrMino

I'm also affected by this issue. I'm using tox. Here's a minimal reproduction example, hopefully matching the example tox.ini found in the docs. https://github.com/Crocmagnon/pip-check-reqs-tox-repro

Crocmagnon avatar Feb 24 '23 09:02 Crocmagnon