-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolving relative dependencies? #200
Comments
It should (there are tests: https://github.com/thebjorn/pydeps/blob/master/tests/test_relative_imports.py). If you have a testcase I can look into it.
Relative imports are kosher in Python. |
Hey thanks for the quick response, in the middle of restructuring my Python dir layout, was using really weird pathing with potentially some circular dependencies along the way, will rerun pydeps after and let you know |
Here, I ran my command from the root of this directory: Here is the file: Here is a snippet of the generated deps file: The generated deps file only shows fastapi and networkx, but it misses both my relative imports and the src.KongBot imports |
I also have the similar problem and one test case for that issue is this file under the repository matplotlib. The error message is shown below Traceback (most recent call last):
..........
File "/$HOME/anaconda3/envs/AA/lib/python3.11/site-packages/pydeps/py2depgraph.py", line 237, in py2dep
mf.run_script(dummy.fname)
File "/$HOME/anaconda3/envs/AA/lib/python3.11/site-packages/pydeps/py2depgraph.py", line 122, in run_script
self.load_module('__main__', fp, pathname, stuff)
File "/$HOME/anaconda3/envs/AA/lib/python3.11/site-packages/pydeps/py2depgraph.py", line 159, in load_module
module = mf27.ModuleFinder.load_module(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/$HOME/anaconda3/envs/AA/lib/python3.11/site-packages/pydeps/mf27.py", line 153, in load_module
self.scan_code(co, m)
File "/$HOME/anaconda3/envs/AA/lib/python3.11/site-packages/pydeps/mf27.py", line 206, in scan_code
parent = self.determine_parent(m, level=level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/$HOME/anaconda3/envs/AA/lib/python3.11/modulefinder.py", line 188, in determine_parent
raise ImportError("relative importpath too deep")
ImportError: relative importpath too deep |
@itaowei interesting. The error is coming from Python's modulefinder module, and indeed if you run in directly you'll see the same result:
If I modify the modulefinder.py code to print out what is causing the problem:
I get the following output:
Which tells me that it isn't due to excessive directory depth in the source tree... Looking at the ps: running modulefinder with maximum debug options doesn't seem to give much more clarity
|
Hmm... it might actually be numpy..?
|
Hey @thebjorn, were you able to root cause the issue? I'm having similar issue with relative path import via
Checking my python3.8 source path directory, all file with Thanks for your help on debugging this! |
Does Pydeps not resolve relative dependencies? (Aside: are relative dependencies considered malpractise in python?)
Following command:
python -m pydeps --show-deps --debug route.py
Does not show any of the relative dependencies imported like so
from .schema import CreateGraphReq, ... from .service import GraphManager, ....
Cheers (also thanks for making this, especially looking forward to using the intermediate output for a project I'm working on for writing automatic test cases)
The text was updated successfully, but these errors were encountered: