damnever / pigar

:coffee: A tool to generate requirements.txt for Python project, and more than that. (IT IS NOT A PACKAGE MANAGEMENT TOOL)

Home Page:https://damnever.github.io/pigar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pigar ignores local packages and cross package references

Gerrit-K opened this issue · comments

Assume the following project structure:

root
  |
  +- foo/
  |  +- foo_module.py
  +- bar/
  |  +- bar_module.py
 +- main.py

And the following contents:

foo_module.py

from bar.bar_module import bar

def foo():
    print('foo')
    bar()

bar_module.py

def bar():
    print('bar')

main.py

from bar.bar_module import bar
from foo.foo_module import foo

if __name__ == '__main__':
    foo()
    bar()

Now, if I run pigar with the following command: pigar -i .venv* -p ./requirements.txt (.venv/ is the location of my virtual environment for this project, so I don't want pigar to scan it, maybe that could be another feature: ignore common virtualenv directory names), I get the following output:

Starting generate requirements ...
The following modules are not found yet:
  bar referenced from:
    foo/foo_module.py: 1
    main.py: 1
  foo referenced from:
    main.py: 2
Some of them may not install in local environment.
Try to search PyPI for the missing modules and filter some unnecessary modules? (y/[N])

Although the packages and modules are clearly present in the current path, pigar seems to ignore them.

Could you put a __init__.py file under your every package directory?

Already tried that, didn't help unfortunately

That is the limitation of pigar, maybe intentional, I need some time to figure it out since I do not use Python for my daily work now.

You can just ignore it for now if you know those are local modules.