Python Snakefood module import generalized failure
Question: I want to run [snakefood](http://furius.ca/snakefood/doc/snakefood-doc.html)
(an AST-based dependency graph analyser; source code can be found
[here](https://bitbucket.org/blais/snakefood/src/e0a74fa6260dcd44716d40b4eb404ca024323eac/lib/python/snakefood/gendeps.py?at=default)).
My project has a structureinvolving several levels of Python packages, like
this:

    
    
    myproject
     |code
      |Utils
       |AdaptedConfigParser
        Configs_Parser.py
        ...
     ...
     main.py
    

However, when I start running snakefood on the root directory of my project it
claims that it can't find the modules from my Python package being imported:

    
    
    $ sfood --internal --follow --ignore-unused ./PycharmProjects/myproject/ > ~/static_analysis.txt
    WARNING     :     Line 9: Could not import module 'myproject.Utils.AdaptedConfigParser.Configs_parser'
    

I tried to get around it by adding a `.pth` file with the project root to the
`lib/python2.7/site-packages`

Now when I call python with that virtual environment activated from anywhere,
I can do the following:

    
    
    $ python
    Python 2.7.6rc1 (default, Jan 19 2014, 18:57:40) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import myproject.Utils.AdaptedConfigParser.Configs_parser
    >>>
    

And it works just fine.

However, when snakefood is launched with that virtual environement, it still
returns the same error.

    
    
    $ sfood --internal --follow --ignore-unused ./PycharmProjects/myproject/ > ~/static_analysis.txt
    WARNING     :     Line 9: Could not import module 'myproject.Utils.AdaptedConfigParser.Configs_parser'
    

At this point I don't even understand where the problem with imports could
come from.

In addition to that, when `--internal` flag is taken away, it fails imports
even of the python `builtin` module, which doesn't make any sense to me:

    
    
    WARNING     :     Line 80: Could not import module 'builtins'
    WARNING     :     Line 190: Could not import module 'pyamg'
    

Have anyone encountered such a problem previously? If yes, is there a way of
getting around it?


Answer: I had similar issues, turns out the warning in my case was generated because
of `__all__` declarations.

e.g.

    
    
    __all__ = ['abc',
               'aaa',
               ...
              ]
    

Above code gives out the warnings:

    
    
    WARNING     :     Line xx: Could not import module 'abc'
    WARNING     :     Line xx: Could not import module 'aaa'
    

I modified the warning constant `ERROR_IMPORT` within
`snakefood\lib\python\find.py` to add the name of the file where the error
occurs along with the line number and module name. That way you can target the
specific file and line number pretty much figure out the problem.

Hope this helps!

