-
Notifications
You must be signed in to change notification settings - Fork 113
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
Support for editable packages / direct_url.json #222
Comments
Editable packages (installed with |
Yes they are indeed installed with pip install -e. Hmm, there is something else going on. Eg (but there are many more, but definitely not on all of them):
I'm running this from within a venv, but that really shouldn't matter right? sys.path looks like this (from where I'm running pydeps):
Any ideas? I'll dig further if I have to, but maybe you can give me some pointers/ideas and save me some time :D |
|
Aah so it just stops looking any deeper then. So this is a legit ImportError 'No module named collections.namedtuple'. But still... there is a dependency on collections none the less? Why does it not include collections then in the dependency graph? I've reduced it to a bare bones example:
Just running pydeps testpackage gives an empty svg:
Running with --include-missing DOES show the actual dependency on collections:
And I realize now that our own custom packages that are missing from the graph have the same issue. They only do "from custompackage import SomeClass" and thus pydeps does not look any deeper and does not include custompackage? Is it that simple? Is this a bug or am I missing something? |
If I add the following line to justimportcollectionsnamedtuple.py
git DOES show up as a dependency... I did some poking around the pydeps code with IPython.embed(). Specifically py2degraph.py > MyModuleFinder > ensure_fromlist (which throws ImportError "No module named..." ). But it's a bit over my head. All I know is that both from collections import namedtuple AND from git import Repo get an ImportError (ImportError: 'No module named git.Repo') But git package DOES get included in the dep graph and collections does not... But what about our own custom package then... Why is it still not included...? I've ran
And it lists our custompackage under "Missing modules:"
But it isn't missing, I can perfectly run that "from custompackage import SomeClass " line from the Python interactive interpreter. |
I've uninstalled the custom editable package and installed it normally (so all files are fysically copied now to site-packages). And now I get errors when running python -m modulefinder testpackage/justimportcollectionsnamedtuple.py
So it seems something is wrong there. I'll google around for any related issues with modulefinder. I welcome any further input or ideas anyone can give me, otherwise this issue can be closed I think. |
I've tried it with the same custom package on another system and it works... Only difference seems to be the Python version. It doesn't work with 3.11.4, it DOES work with 3.112. I'm gonna see if i can down (or up)grade the Python version of the first one. See if it makes a difference. |
I've downgraded to Python 3.9.2 in my original environment and And pydeps, consequently, also works. It now shows our custom package. I have only been able to find this related issue, so it seems there is some kind of regression in modulefinder? But our custompackage does not use namespaces (there is an init.py). I'll see if upgrading to a newer Python version also fixes it. But I'm on Debian, so not always easy. Anyway: it does not seem to be a problem with Pydeps! |
I've traced the issue back to the preinstalled Python version on the Microsoft provider Docker images: https://github.com/devcontainers/images/tree/main/src/python On the latest version of the Docker image (3.12-bookworm) modulefinder also doesn't find the package if installed as editable. If I switch to the OS (Debian) provided Python version in the image it all works. I'm going to report this issue on the devcontainers project. Thank you for your time and your awesome project! I've managed to get what I want now by using this latest Docker image and temporarily installing our custompackage as normal instead of editable. |
Good detective work :-) |
Hello,
Does pydeps currently support editable packages (using hint in direct_url.json in the .dist-info directory) ?
See also this related mypy issue that explains it much better: python/mypy#12313
I'm currently chasing an issue with packages missing from the dependency graph and I think this is the issue. Would be nice if anyone could confirm it :)
UPDATE: And might there be a way to workaround this issue by modifying the sys.path for pydeps so I can point to the files/packages directly (thus skipping direct_url.json) ?
I'v tried providing PYTHONPATH to pydeps, but that doesn't seem to work :/
The text was updated successfully, but these errors were encountered: