Skip to content

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

@theahura

Description

@theahura

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/

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions