Comments (7)
Just tried pydeps
after using it a long time ago on the project I work on. We recently moved to namespace packages too, and now instead of the nice graph, I get only three nodes in the graph, and only if I specify pydeps cylc/flow
. It fails when running pydeps cylc
(parent directory). Looks like it's an issue with modulefinder
, so hopefully that'll be fixed soon there, so that I can use pydeps
again 🤞
from pydeps.
That is a huge bug and --include-missing
seems to avoid it but not without nasty side effects. Sadly I will not be able to adopt pydeps as part of the docs until is fixed.
from pydeps.
modulegraph seems to be built on the same foundational technology and does some work to support namespace packages (https://github.com/ronaldoussoren/modulegraph/blob/master/modulegraph/modulegraph.py#L63)
from pydeps.
Hi @gdetrez and thank you for the bugreport.
modulefinder
can't find pkg1 and reports it as "Missing" (internally it calls it a bad module ;-)
c:\srv\tmp\pep420>\Python34\python.exe -m modulefinder main.py
Name File
---- ----
m __main__ main.py
P pkg2 pkg2\__init__.py
m pkg2.bar pkg2\bar.py
Missing modules:
? pkg1.foo imported from __main__
pydeps --externals
will list "bad modules":
c:\srv\tmp\pep420>pydeps --externals main.py
[
"pkg1",
"pkg2"
]
I suppose we could include all the "bad" modules in the graph as well, but with the current code they would be empty.
The best alternative would be to fix pydeps' copy of modulefinder (mf27.py
) to also find PEP420 modules, but at this point I'm not sure if that's even possible...?
from pydeps.
Hi @thebjorn. Sorry for the radio silence.
I see that if I use the --include-missing
flag, I get a bit more complete picture. But it seems that I don't get the transitive dependencies of the namespaced package (i.e if main
imports ns1.foo
and ns1.foo
import ns1.bar
, the latter is not included in the graph).
While researching the same issue for mypy, I found python/mypy#5691 which implement PEP 420 support (it's behind a --namespace-packages
flag). The module is also called modulefinder
but it looks rather different than the one here so I'm not sure how much is reusable.
Otherwise, if you don't mind the extra dependency, maybe it'd be worth taking a look at modulegraph
by Ronald Oussoren, which already supports namespaces:
❯❯❯ python3 -m modulegraph main.py
Class Name File
----- ---- ----
Script /home/gregoire/experiments/20190128-pydeps-namespace/test2/main.py /home/gregoire/experiments/20190128-pydeps-namespace/test2/main.py
NamespacePackage ns1 -
SourceModule ns1.bar /home/gregoire/experiments/20190128-pydeps-namespace/test2/ns1/bar.py
SourceModule ns1.foo /home/gregoire/experiments/20190128-pydeps-namespace/test2/ns1/foo.py
from pydeps.
@ssbarnea I'm wondering if you're using this feature to create namespace package, or if it's simply to avoid having an __init__.py
file? I've never found a reason to use namespace packages that outweigh the mess it causes. Regardless, pydeps
is dependent on modulefinder
(a python standard module - vendorized with some bug-fixes) supporting the feature first. I'll happily merge a PR if you or anyone else wants to work on it though...
from pydeps.
Thanks, will keep it in mind. Decided to go with findimports
. It is fast and does the trick for the time being. Although it doesn't have good clustering / collapsing, my needs are still simple enough for it to not be a problem.
When I need something more extensive & customisable I will have a look at modulegraph
, pydeps
and findmodules
in more depth.
from pydeps.
Related Issues (20)
- feature: exclude externals deps HOT 5
- Pydeps: Support compiled python filename HOT 2
- [Problem already solved, you can close this]
- The cycles display mode shows useless information and does not work properly for larger projects. HOT 8
- [Feature Request] Specify module name instead of filename HOT 4
- Resolving relative dependencies? HOT 7
- Support for namespace packages HOT 1
- use of `--externals` results in TypeError: 'Config' object does not support item assignment HOT 1
- --dot-output option is not effective HOT 1
- Support output markdown mermaid HOT 1
- empty result with WARNING: SKIPPING ILLEGAL MODULE_NAME: D:.test.a HOT 2
- Support for specifying more than one `fname`
- 1.12.19: pitest fails in `tests/test_package_names.py::test_find_package_names` unit HOT 2
- `--exclude` option not working HOT 1
- Show only top-level imports HOT 1
- Exclude/include dependencies by filepath HOT 1
- Add type hints HOT 1
- Use of pydeps in CI to reject introduction of new import cycles? HOT 3
- Constrain output geometry / size HOT 2
- pydeps randomly generates compiled pyc files when examine python source file HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pydeps.