1PYDEPS(1) pydeps PYDEPS(1)
2
3
4
6 pydeps - pydeps Documentation Documentation StatusDownloads
7
8 Python module dependency visualization.
9
10 This package is primarily intended to be used from the command line
11 through the pydeps command.
12
13 Contents
14 • pydeps
15
16 • How to install
17
18 • Usage
19
20 • Example
21
22 • Notes
23
24 • Configuration files
25
26 • Bacon (Scoring)
27
28 • Import cycles
29
30 • Clustering
31
32 • Maximum module depth
33
34 • Graph direction
35
36 • Collapsing target package
37
38 • Intermediate format
39
40 • Version history
41
42 • Contributing
43
44 • API documentation
45
46 • Module contents
47
48 • pydeps.arguments module
49
50 • pydeps.cli module
51
52 • pydeps.colors module
53
54 • pydeps.depgraph module
55
56 • pydeps.depgraph2dot module
57
58 • pydeps.dot module
59
60 • pydeps.dummymodule module
61
62 • pydeps.configs module
63
64 • pydeps.mf27 module
65
66 • pydeps.package_names module
67
68 • pydeps.py2depgraph module
69
70 • pydeps.pycompat module
71
72 • pydeps.pydeps module
73
74 • pydeps.pystdlib module
75
76 • pydeps.render_context module
77
78 • pydeps.target module
79
80 • Indices and tables
81
82 Feature requests and bug reports:
83
84 Please report bugs and feature requests on GitHub at
85 https://github.com/thebjorn/pydeps/issues
86
88 pip install pydeps
89
90 To create graphs with pydeps you also need to install Graphviz. Please
91 follow the installation instructions provided in the Graphviz link (and
92 make sure the dot command is on your path).
93
95 usage: pydeps [-h] [--debug] [--config FILE] [--no-config] [--version] [-L LOG]
96 [--find-package] [-v] [-o file] [-T FORMAT] [--display PROGRAM]
97 [--noshow] [--show-deps] [--show-raw-deps] [--deps-output DEPS_OUT]
98 [--show-dot] [--dot-output DOT_OUT] [--nodot] [--no-output]
99 [--show-cycles] [--debug-mf INT] [--noise-level INT]
100 [--max-bacon INT] [--max-module-depth INT] [--pylib] [--pylib-all]
101 [--include-missing] [-x PATTERN [PATTERN ...]]
102 [-xx MODULE [MODULE ...]] [--only MODULE_PATH [MODULE_PATH ...]]
103 [--externals] [--reverse] [--rankdir {TB,BT,LR,RL}] [--cluster]
104 [--min-cluster-size INT] [--max-cluster-size INT]
105 [--keep-target-cluster] [--collapse-target-cluster]
106 [--rmprefix PREFIX [PREFIX ...]] [--start-color INT]
107 fname
108
109 positional arguments:
110 fname filename
111
112 optional arguments:
113
114 -h, --help
115 show this help message and exit
116
117 --debug
118 turn on all the show and verbose options (mainly for de‐
119 bugging pydeps itself)
120
121 --config FILE
122 specify config file
123
124 --no-config
125 disable processing of config files
126
127 --version
128 print pydeps version
129
130 -L LOG, --log LOG
131 set log-level to one of CRITICAL, ERROR, WARNING, INFO,
132 DEBUG, NOTSET.
133
134 --find-package
135 tries to automatically find the name of the current pack‐
136 age.
137
138 -v, --verbose
139 be more verbose (-vv, -vvv for more verbosity)
140
141 -o file
142 write output to 'file'
143
144 -T FORMAT
145 output format (svg|png)
146
147 --display PROGRAM
148 program to use to display the graph (png or svg file de‐
149 pending on the T parameter)
150
151 --noshow, --no-show
152 don't call external program to display graph
153
154 --show-deps
155 show output of dependency analysis
156
157 --show-raw-deps
158 show output of dependency analysis before removing skips
159
160 --deps-output
161 write output of dependency analysis to file (instead of
162 screen)
163
164 --show-dot
165 show output of dot conversion
166
167 --dot-output
168 write dot code to file (instead of screen)
169
170 --nodot, --no-dot
171 skip dot conversion
172
173 --no-output
174 don't create .svg/.png file, implies --no-show (-t/-o
175 will be ignored)
176
177 --show-cycles
178 show only import cycles
179
180 --debug-mf INT
181 set the ModuleFinder.debug flag to this value
182
183 --noise-level INT
184 exclude sources or sinks with degree greater than
185 noise-level
186
187 --max-bacon INT
188 exclude nodes that are more than n hops away (default=2,
189 0 -> infinite)
190
191 --max-module-depth INT
192 coalesce deep modules to at most n levels
193
194 --pylib
195 include python std lib modules
196
197 --pylib-all
198 include python all std lib modules (incl. C modules)
199
200 --include-missing
201 include modules that are not installed (or can't be found
202 on sys.path)
203
204 --only MODULE_PATH
205 only include modules that start with MODULE_PATH, multi‐
206 ple paths can be provided
207
208 --externals
209 create list of direct external dependencies
210
211 --reverse
212 draw arrows to (instead of from) imported modules
213
214 --rankdir
215 set the direction of the graph, legal values are TB (de‐
216 fault, imported modules above importing modules), BT (op‐
217 posite direction of TB), LR (left-to-right) and RL
218 (right-to-left)
219
220 --cluster
221 draw external dependencies as separate clusters
222
223 --min-cluster-size INT
224 the minimum number of nodes a dependency must have before
225 being clustered (default=0)
226
227 --max-cluster-size INT
228 the maximum number of nodes a dependency can have before
229 the cluster is collapsed to a single node (default=0)
230
231 --keep-target-cluster
232 draw target module as a cluster
233
234 --collapse-target-cluster
235 collapse target module (this implies --cluster)
236
237 --rmprefix PREFIX
238 remove PREFIX from the displayed name of the nodes (mul‐
239 tiple prefixes can be provided)
240
241 -x PATTERN, --exclude PATTERN
242 input files to skip (e.g. foo.*), multiple patterns can
243 be provided
244
245 --exclude-exact MODULE
246 (shorthand -xx MODULE) same as --exclude, except requires
247 the full match. -xx foo.bar will exclude foo.bar, but not
248 foo.bar.blob
249
250 Note: if an option with a variable number of arguments (like -x) is
251 provided before fname, separate the arguments from the filename with --
252 otherwise fname will be parsed as an argument of the option. Example: $
253 pydeps -x os sys -- pydeps.
254
255 You can of course also import pydeps from Python and use it as a li‐
256 brary, look in tests/test_relative_imports.py for examples.
257
259 This is the result of running pydeps on itself (pydeps pydeps): [image]
260
261 (full disclosure: this is for an early version of pydeps)
262
264 pydeps finds imports by looking for import-opcodes in python bytecodes
265 (think .pyc files). Therefore, only imported files will be found (ie.
266 pydeps will not look at files in your directory that are not imported).
267 Additionally, only files that can be found using the Python import ma‐
268 chinery will be considered (ie. if a module is missing or not in‐
269 stalled, it will not be included regardless if it is being imported).
270 This can be modified by using the --include-missing flag.
271
272 Displaying the graph:
273
274 To display the resulting .svg or .png files, pydeps by default calls an
275 appropriate opener for the platform, like xdg-open foo.svg.
276
277 This can be overridden with the --display PROGRAM option, where PROGRAM
278 is an executable that can display the image file of the graph.
279
280 You can also export the name of such a viewer in either the PYDEPS_DIS‐
281 PLAY or BROWSER environment variable, which changes the default behav‐
282 iour when --display is not used.
283
285 All options can also be set in a .pydeps file using .ini file syntax
286 (parsable by ConfigParser). Command line options override options in
287 the .pydeps file in the current directory, which again overrides op‐
288 tions in the user's home directory (%USERPROFILE%\.pydeps on Windows
289 and ${HOME}/.pydeps otherwise).
290
291 An example .pydeps file:
292
293 [pydeps]
294 max_bacon = 2
295 no_show = True
296 verbose = 0
297 pylib = False
298 exclude =
299 os
300 re
301 sys
302 collections
303 __future__
304
305 pydeps will also look for configuration data in pyproject.toml (under
306 [tool.pydeps]) and setup.cfg (under [pydeps]).
307
309 pydeps also contains an Erdős-like scoring function (a.k.a. Bacon num‐
310 ber, from Six degrees of Kevin Bacon (‐
311 http://en.wikipedia.org/wiki/Six_Degrees_of_Kevin_Bacon) that lets you
312 filter out modules that are more than a given number of 'hops' away
313 from the module you're interested in. This is useful for finding the
314 interface a module has to the rest of the world.
315
316 To find pydeps' interface to the Python stdlib (less some very common
317 modules).
318
319 shell> pydeps pydeps --show --max-bacon 2 --pylib -x os re types _* enum
320 [image]
321
322 --max-bacon 2 (the default) gives the modules that are at most 2 hops
323 away, and modules that belong together have similar colors. Compare
324 that to the output with the --max-bacon=0 (infinite) filter: [image]
325
327 pydeps can detect and display cycles with the --show-cycles parameter.
328 This will _only_ display the cycles, and for big libraries it is not a
329 particularly fast operation. Given a folder with the following con‐
330 tents (this uses yaml to define a directory structure, like in the
331 tests):
332
333 relimp:
334 - __init__.py
335 - a.py: |
336 from . import b
337 - b.py: |
338 from . import a
339
340 pydeps relimp --show-cycles displays: [image]
341
343 Running pydeps pydeps --max-bacon=4 on version 1.8.0 of pydeps gives
344 the following graph: [image]
345
346 If you are not interested in the internal structure of external mod‐
347 ules, you can add the --cluster flag, which will collapse external mod‐
348 ules into folder-shaped objects:
349
350 shell> pydeps pydeps --max-bacon=4 --cluster
351 [image]
352
353 To see the internal structure _and_ delineate external modules, use the
354 --max-cluster-size flag, which controls how many nodes can be in a
355 cluster before it is collapsed to a folder icon:
356
357 shell> pydeps pydeps --max-bacon=4 --cluster --max-cluster-size=1000
358 [image]
359
360 or, using a smaller max-cluster-size:
361
362 shell> pydeps pydeps --max-bacon=4 --cluster --max-cluster-size=3
363 [image]
364
365 To remove clusters with too few nodes, use the --min-cluster-size flag:
366
367 shell> pydeps pydeps --max-bacon=4 --cluster --max-cluster-size=3 --min-cluster-size=2
368 [image]
369
370 In some situations it can be useful to draw the target module as a
371 cluster:
372
373 shell> pydeps pydeps --max-bacon=4 --cluster --max-cluster-size=3 --min-cluster-size=2 --keep-target-cluster
374 [image]
375
376 ..and since the cluster boxes include the module name, we can remove
377 those prefixes:
378
379 shell> pydeps pydeps --max-bacon=4 --cluster --max-cluster-size=3 --min-cluster-size=2 --keep-target-cluster --rmprefix pydeps. stdlib_list.
380 [image]
381
383 For Python packages that have a module structure more than two levels
384 deep, the graph can easily become overwhelmingly complex. Use the
385 --max-module-depth=n flag to examine the internal dependencies of a
386 package while limiting the module depth (private and testing-related
387 modules are removed to further simplify the graph using -x ...):
388
389 shell> pydeps pandas --only pandas --max-module-depth=2 -x pandas._* pandas.test* pandas.conftest
390 [image]
391
393 The direction of the graph can be specified using the --rankdir flag.
394
395 Top to bottom (default):
396
397 shell> pydeps pydeps --rankdir TB
398 [image]
399
400 Bottom to top:
401
402 shell> pydeps pydeps --rankdir BT
403 [image]
404
405 Left to right:
406
407 shell> pydeps pydeps --rankdir LR
408 [image]
409
410 Right to left:
411
412 shell> pydeps pydeps --rankdir RL
413 [image]
414
416 When internal target package dependencies are unimportant, they can be
417 collapsed using the --collapse-target-cluster flag. This option also
418 implies --cluster:
419
420 shell> pydeps pydeps --collapse-target-cluster
421 [image]
422
424 An attempt has been made to keep the intermediate formats readable, eg.
425 the output from pydeps --show-deps .. looks like this:
426
427 ...
428 "pydeps.mf27": {
429 "imported_by": [
430 "__main__",
431 "pydeps.py2depgraph"
432 ],
433 "kind": "imp.PY_SOURCE",
434 "name": "pydeps.mf27",
435 "path": "pydeps\\mf27.py"
436 },
437 "pydeps.py2depgraph": {
438 "imported_by": [
439 "__main__",
440 "pydeps.pydeps"
441 ],
442 "imports": [
443 "pydeps.depgraph",
444 "pydeps.mf27"
445 ],
446 "kind": "imp.PY_SOURCE",
447 "name": "pydeps.py2depgraph",
448 "path": "pydeps\\py2depgraph.py"
449 }, ...
450
452 Version 1.12.13 Better docs for larger packages. See
453 maximum_module_depth for an example. Thanks to sheromon for the PR.
454
455 Version 1.12.5 Pydeps can now read configuration data from pypro‐
456 ject.toml. Thanks to septatrix for pushing the idea and for countering
457 my toml-rant with an informative argument.
458
459 Version 1.11.0 drop support for Python 3.6. Thanks to pawamoy for re‐
460 moving imports of the deprecated imp module. (Parts of it has been
461 vendorized due to a Python bug, see the code for details.)
462
463 Version 1.10.1 Thanks to vector400 for a new option --rankdir which
464 renders the graph in different directions.
465
466 Version 1.10.0 supports Python 3.10.
467
468 Version 1.9.15 Thanks to Pipeline Foundation for a very much improved
469 CI pipeline, and a CD pipeline as well.
470
471 Version 1.9.14 Thanks to poneill for fixing a cryptic error message
472 when run in a directory without an __init__.py file.
473
474 Version 1.9.13 Thanks to glumia and SimonBiggs for improving the docu‐
475 mentation.
476
477 Version 1.9.10 no_show is now honored when placed in .pydeps file.
478 Thanks to romain-dartigues for the PR.
479
480 Version 1.9.8 Fix for maximum recursion depth exceeded when using large
481 frameworks (like sympy). Thanks to tanujkhattar for finding the fix
482 and to balopat for reporting it.
483
484 Version 1.9.7 Check PYDEPS_DISPLAY and BROWSER for a program to open
485 the graph, PR by jhermann
486
487 Version 1.9.1 graphs are now stable on Python 3.x as well - this was
488 already the case for Py2.7 (thanks to pawamoy for reporting and testing
489 the issue and to kinow for helping with testing).
490
491 Version 1.9.0 supports Python 3.8.
492
493 Version 1.8.7 includes a new flag --rmprefix which lets you remove pre‐
494 fixes from the node-labels in the graph. The _name_ of the nodes are
495 not effected so this does not cause merging of nodes, nor does it
496 change coloring - but it can lead to multiple nodes with the same label
497 (hovering over the node will give the full name). Thanks to aroberge
498 for the enhancement request.
499
500 Version 1.8.5 With svg as the output format (which is the default),
501 paths are now hilighted on mouse hover (thanks to tomasito665 for the
502 enhancement request).
503
504 Version 1.8.2 incldes a new flag --only that causes pydeps to only re‐
505 port on the paths specified:
506
507 shell> pydeps mypackage --only mypackage.a mypackage.b
508
509 Version 1.8.0 includes 4 new flags for drawing external dependencies as
510 clusters. See clustering for examples. Additionally, the arrowheads
511 now have the color of the source node.
512
513 Version 1.7.3 includes a new flag -xx or --exclude-exact which matches
514 the functionality of the --exclude flag, except it requires an exact
515 match, i.e. -xx foo.bar will exclude foo.bar, but not foo.bar.blob
516 (thanks to AvenzaOleg for the PR).
517
518 Version 1.7.2 includes a new flag, --no-output, which prevents creation
519 of the .svg/.png file.
520
521 Version 1.7.1 fixes excludes in .pydeps files (thanks to eqvis for the
522 bug report).
523
524 Version 1.7.0 The new --reverse flag reverses the direction of the ar‐
525 rows in the dependency graph, so they point _to_ the imported module
526 instead of _from_ the imported module (thanks to goetzk for the bug re‐
527 port and tobiasmaier for the PR!).
528
529 Version 1.5.0 Python 3 support (thanks to eight04 for the PR).
530
531 Version 1.3.4 --externals will now include modules that haven't been
532 installed (what modulefinder calls badmodules).
533
534 Version 1.2.8 A shortcut for finding the direct external dependencies
535 of a package was added:
536
537 pydeps --externals mypackage
538
539 which will print a json formatted list of module names to the screen,
540 e.g.:
541
542 (dev) go|c:\srv\lib\dk-tasklib> pydeps --externals dktasklib
543 [
544 "dkfileutils"
545 ]
546
547 which means that the dktasklib package only depends on the dkfileutils
548 package.
549
550 This functionality is also available programmatically:
551
552 import os
553 from pydeps.pydeps import externals
554 # the directory that contains setup.py (one level up from actual package):
555 os.chdir('package-directory')
556 print externals('mypackage')
557
558 Version 1.2.5: The defaults are now sensible, such that:
559
560 shell> pydeps mypackage
561
562 will likely do what you want. It is the same as pydeps --show --max-ba‐
563 con=2 mypackage which means display the dependency graph in your
564 browser, but limit it to two hops (which includes only the modules that
565 your module imports -- not continuing down the import chain). The old
566 default behavior is available with pydeps --noshow --max-bacon=0 my‐
567 package.
568
570 1. Fork it
571
572 2. It is appreciated (but not required) if you raise an issue first:
573 https://github.com/thebjorn/pydeps/issues
574
575 3. Create your feature branch (git checkout -b my-new-feature)
576
577 4. Commit your changes (git commit -am 'Add some feature')
578
579 5. Push to the branch (git push origin my-new-feature)
580
581 6. Create new Pull Request
582
584 Python module dependency visualization. This package installs the py‐
585 deps command, and normal usage will be to use it from the command line.
586
588 class pydeps.arguments.Argument(*flags, **args)
589 Bases: object
590
591 add_to_parser(parser)
592
593 argname()
594
595 default()
596
597 help()
598
599 pytype()
600
601 typefn()
602
603 typename()
604
605 class pydeps.arguments.Arguments(config_files=None, debug=False,
606 *posargs, parents=None, **kwargs)
607 Bases: object
608
609 add(*flags, **kwargs)
610
611 load_config_files()
612
613 parse_args(argv)
614
615 write_default_config()
616 Utility function to create .configs.Config
617
618 # XXX: a more general utility to create configs from arg‐
619 parse # would be nice...
620
621 class pydeps.arguments.Namespace(ns)
622 Bases: object
623
624 items()
625
627 command line interface (cli) code.
628
629 pydeps.cli.base_argparser(argv=())
630 Initial parser that can set values for the rest of the parsing
631 process.
632
633 pydeps.cli.error(*args, **kwargs)
634 Print an error message and exit.
635
636 pydeps.cli.parse_args(argv=())
637 Parse command line arguments, and return a dict.
638
639 pydeps.cli.verbose(*args, **kwargs)
640 the (will become) verbose function
641
643 Color calculations.
644
645 class pydeps.colors.ColorSpace(nodes)
646 Bases: object
647
648 add_to_tree(parts, tree)
649
650 color(src)
651
652 pydeps.colors.brightness(r, g, b)
653 From w3c (range 0..255).
654
655 pydeps.colors.brightnessdiff(a, b)
656 greater than 125 is good.
657
658 pydeps.colors.colordiff(rgb1, rgb2)
659 From w3c (greater than 500 is good). (range [0..765])
660
661 pydeps.colors.distinct_hues(count)
662 Return count hues, equidistantly spaced.
663
664 pydeps.colors.foreground(background, *options)
665 Find the best foreground color from options based on background
666 color.
667
668 pydeps.colors.frange(start, end, step)
669 Like range(), but with floats.
670
671 pydeps.colors.name2rgb(hue)
672 Originally used to calculate color based on module name.
673
674 pydeps.colors.rgb2css(rgb)
675 Convert rgb to hex.
676
677 pydeps.colors.rgb2eightbit(rgb)
678 Convert floats in [0..1] to integers in [0..256)
679
681 class pydeps.depgraph.DepGraph(depgraf, types, target, **args)
682 Bases: object
683
684 The dependency graph.
685
686 It is the output of pydeps.py2depgraph.py2dep()
687
688 add_source(src)
689
690 calculate_bacon()
691
692 connect_generations()
693 Traverse depth-first adding imported_by.
694
695 dissimilarity_metric(a, b)
696 Return non-zero if references to this module are strange,
697 and should be drawn extra-long. The value defines the
698 length, in rank. This is also good for putting some ver‐
699 tical space between seperate subsystems.
700
701 Returns an int between 1 (default) and 4 (highly unre‐
702 lated).
703
704 exclude_bacon(limit)
705 Exclude modules that are more than limit hops away from
706 __main__.
707
708 exclude_noise()
709
710 find_import_cycles()
711
712 get_colors(src, colorspace=None)
713
714 levelcounts()
715
716 only_filter(paths)
717 Exclude nodes that have a prefix in paths.
718
719 proximity_metric(a, b)
720 Return the weight of the dependency from a to b. Higher
721 weights usually have shorter straighter edges. Return 1
722 if it has normal weight. A value of 4 is usually good for
723 ensuring that a related pair of modules are drawn next to
724 each other.
725
726 Returns an int between 1 (unknown, default), and 4 (very
727 related).
728
729 remove_excluded()
730 Remove all sources marked as excluded.
731
732 skip_modules = ['os', 'sys', 'qt', 'time', '__future__',
733 'types', 're', 'string', 'bdb', 'pdb', '__main__', 'south']
734
735 source_name(name, path=None)
736 Returns the module name, possibly limited by --max-mod‐
737 ule-depth.
738
739 sources
740 dict[module_name] -> Source object
741
742 class pydeps.depgraph.Source(name, path=None, imports=(), ex‐
743 clude=False, args=None)
744 Bases: object
745
746 A node (contained) in the dependency graph.
747
748 It contains info about which modules are imported by this
749 source, and which modules import this source.
750
751 property degree
752
753 get_label(splitlength=0, rmprefix=None)
754
755 property in_degree
756 Number of incoming arrows.
757
758 is_noise()
759 Is this module just noise? (too common either at top or
760 bottom of the graph).
761
762 property label
763 Convert a module name to a formatted node label. This is
764 a default policy - please override.
765
766 property module_depth
767
768 property name_parts
769
770 property out_degree
771 Number of outgoing arrows.
772
773 property path_parts
774
775 class pydeps.depgraph.imp(value, names=None, *values, module=None,
776 qualname=None, type=None, start=1, boundary=None)
777 Bases: Enum
778
779 C_BUILTIN = 6
780
781 C_EXTENSION = 3
782
783 IMP_HOOK = 9
784
785 PKG_DIRECTORY = 5
786
787 PY_CODERESOURCE = 8
788
789 PY_COMPILED = 2
790
791 PY_FROZEN = 7
792
793 PY_RESOURCE = 4
794
795 PY_SOURCE = 1
796
797 UNKNOWN = 0
798
800 class pydeps.depgraph2dot.CycleGraphDot(**kw)
801 Bases: object
802
803 render(depgraph, ctx)
804
805 class pydeps.depgraph2dot.PyDepGraphDot(**kw)
806 Bases: object
807
808 render(depgraph, ctx)
809
810 pydeps.depgraph2dot.cycles2dot(target, depgraph, **kw)
811
812 pydeps.depgraph2dot.dep2dot(target, depgraph, **kw)
813
815 Graphviz interface.
816
817 pydeps.dot.call_graphviz_dot(src, fmt)
818 Call dot command, and provide helpful error message if we cannot
819 find it.
820
821 pydeps.dot.cmd2args(cmd)
822 Prepare a command line for execution by Popen.
823
824 pydeps.dot.display_svg(kw, fname)
825 Try to display the svg file on this platform.
826
827 Note that this is also used to display PNG files, despite the
828 name.
829
830 pydeps.dot.dot(src, **kw)
831 Execute the dot command to create an svg output.
832
833 pydeps.dot.in_wsl()
834 Are we running under wsl?
835
836 pydeps.dot.is_unicode(s)
837 Test unicode with py3 support.
838
839 pydeps.dot.pipe(cmd, txt)
840 Pipe txt into the command cmd and return the output.
841
842 pydeps.dot.to_bytes(s)
843 Convert an item into bytes.
844
846 class pydeps.dummymodule.DummyModule(target, **args)
847 Bases: object
848
849 We create a file that imports the module to be investigated.
850
851 legal_module_name(name)
852 Legal module names are dotted strings where each part is
853 a valid Python identifier. (and not a keyword, and sup‐
854 port unicode identifiers in Python3, ..)
855
856 print_header(fp)
857
858 print_import(fp, module)
859
860 text() Return the content of the dummy module.
861
862 pydeps.dummymodule.fname2modname(fname, package_root)
863
864 pydeps.dummymodule.is_module(directory)
865 A directory is a module if it contains an __init__.py file.
866
867 pydeps.dummymodule.is_pysource(fname)
868 A file name is a python source file iff it ends with '.py(w?)'
869 and doesn't start with a dot.
870
871 pydeps.dummymodule.python_sources_below(directory, package=True)
872
874 class pydeps.configs.Config(**kwargs)
875 Bases: object
876
877 cluster = False
878 draw external dependencies as separate clusters
879
880 collapse_target_cluster = False
881 collapse target module (--keep-target-cluster will be ig‐
882 nored)
883
884 config = None
885 specify config file
886
887 debug = False
888 turn on all the show and verbose options (mainly for de‐
889 bugging pydeps itself)
890
891 debug_mf = 0
892 set the ModuleFinder.debug flag to this value
893
894 deps_out = None
895 write output of dependency analysis to 'file'
896
897 display = None
898 program to use to display the graph (png or svg file de‐
899 pending on the T parameter)
900
901 dot_out = None
902 write dot code to 'file'
903
904 exclude = []
905 input files to skip (e.g. foo.*), multiple file names can
906 be provided
907
908 exclude_exact = []
909 same as --exclude, except requires the full match. -xx
910 foo.bar will exclude foo.bar, but not foo.bar.blob
911
912 externals = False
913 create list of direct external dependencies
914
915 find_package = False
916 tries to automatically find the name of the current pack‐
917 age.
918
919 fname = None
920 filename
921
922 format = 'svg'
923 output format (svg|png)
924
925 include_missing = False
926 include modules that are not installed (or can't be found
927 on sys.path)
928
929 keep_target_cluster = False
930 draw target module as a cluster
931
932 classmethod load(fnames)
933 Load config from file.
934
935 log = None
936 set log-level to one of CRITICAL, ERROR, WARNING, INFO,
937 DEBUG, NOTSET.
938
939 max_bacon = 2
940 exclude nodes that are more than n hops away (default=2,
941 0 -> infinite)
942
943 max_cluster_size = 0
944 the maximum number of nodes a dependency can have before
945 the cluster is collapsed to a single node (default=0)
946
947 max_module_depth = 0
948 coalesce deep modules to at most n levels
949
950 min_cluster_size = 0
951 the minimum number of nodes a dependency must have before
952 being clustered (default=0)
953
954 no_config = False
955 disable processing of config files
956
957 no_dot = False
958 skip dot conversion
959
960 no_output = False
961 don't create .svg/.png file, implies --no-show (-t/-o
962 will be ignored)
963
964 no_show = False
965 don't call external program to display graph
966
967 noise_level = 200
968 exclude sources or sinks with degree greater than
969 noise-level
970
971 only = []
972 only include modules that start with MODULE_PATH
973
974 output = None
975 write output to 'file'
976
977 pylib = False
978 include python std lib modules
979
980 pylib_all = False
981 include python all std lib modules (incl. C modules)
982
983 rankdir = 'TB'
984 set the direction of the graph, legal values are TB (de‐
985 fault, imported modules above importing modules), BT (op‐
986 posite direction of TB), BT (opposite direction of TB),
987 LR (left-to-right) and RL (right-to-left)
988
989 reverse = False
990 draw arrows to (instead of from) imported modules
991
992 rmprefix = []
993 remove PREFIX from the displayed name of the nodes
994
995 set_field(field, value)
996
997 show_cycles = False
998 show only import cycles
999
1000 show_deps = False
1001 show output of dependency analysis
1002
1003 show_dot = False
1004 show output of dot conversion
1005
1006 show_raw_deps = False
1007 show output of dependency analysis before removing skips
1008
1009 start_color = 0
1010 starting value for hue from 0 (red/default) to 360.
1011
1012 update(data)
1013
1014 verbose = 0
1015 be more verbose (-vv, -vvv for more verbosity)
1016
1017 version = False
1018 print pydeps version
1019
1020 write_ini()
1021
1022 write_json()
1023
1024 write_toml()
1025
1026 write_yaml()
1027
1028 pydeps.configs.boolval(v)
1029
1030 pydeps.configs.filetype(fname)
1031
1032 pydeps.configs.identity(v)
1033
1034 pydeps.configs.is_string(v)
1035
1036 pydeps.configs.listval(v)
1037
1038 pydeps.configs.load_config(filename)
1039
1040 pydeps.configs.load_ini(filename)
1041
1042 pydeps.configs.load_json(filename)
1043
1044 pydeps.configs.load_toml(filename)
1045
1046 pydeps.configs.load_yaml(filename)
1047
1049 class pydeps.mf27.ModuleFinder(path=None, debug=0, excludes=None, re‐
1050 place_paths=None)
1051 Bases: ModuleFinder
1052
1053 import_hook(name, caller=None, fromlist=None, level=-1)
1054
1055 load_module(fqname, fp, pathname, file_info)
1056
1057 scan_code(co, m)
1058
1059 pydeps.mf27.load_pyc(fp, mf=None)
1060 Load a pyc file from a file object.
1061
1063 pydeps.package_names.find_package_names()
1064
1066 class pydeps.py2depgraph.Module(name, file=None, path=None)
1067 Bases: object
1068
1069 property shortname
1070
1071 class pydeps.py2depgraph.MyModuleFinder(syspath, *args, **kwargs)
1072 Bases: ModuleFinder
1073
1074 add_module(fqname)
1075
1076 ensure_fromlist(module, fromlist, recursive=0)
1077
1078 import_hook(name, caller=None, fromlist=None, level=-1)
1079
1080 import_module(partnam, fqname, parent)
1081
1082 load_module(fqname, fp, pathname, suffix_mode_kind)
1083
1084 run_script(pathname)
1085
1086 class pydeps.py2depgraph.RawDependencies(fname, **kw)
1087 Bases: object
1088
1089 class pydeps.py2depgraph.imp(value, names=None, *values, module=None,
1090 qualname=None, type=None, start=1, boundary=None)
1091 Bases: IntEnum
1092
1093 C_BUILTIN = 6
1094
1095 C_EXTENSION = 3
1096
1097 IMP_HOOK = 9
1098
1099 PKG_DIRECTORY = 5
1100
1101 PY_CODERESOURCE = 8
1102
1103 PY_COMPILED = 2
1104
1105 PY_FROZEN = 7
1106
1107 PY_RESOURCE = 4
1108
1109 PY_SOURCE = 1
1110
1111 pydeps.py2depgraph.py2dep(target, **kw) -> DepGraph
1112 "Calculate dependencies for pattern and return a DepGraph.
1113
1114 pydeps.py2depgraph.py2depgraph()
1115
1117 Compatibility imports between py2/py3
1118
1120 cli entrypoints.
1121
1122 pydeps.pydeps.call_pydeps(file_or_dir, **kwargs)
1123 Programatic entry point for pydeps.
1124
1125 See pydeps.configs.Config class for the available options.
1126
1127 pydeps.pydeps.depgraph_to_dotsrc(target, dep_graph, **kw)
1128 Convert the dependency graph (DepGraph class) to dot source
1129 code.
1130
1131 pydeps.pydeps.externals(trgt, **kwargs)
1132 Return a list of direct external dependencies of pkgname.
1133 Called for the pydeps --externals command.
1134
1135 pydeps.pydeps.pydeps(**args)
1136 Entry point for the pydeps command.
1137
1138 This function should do all the initial parameter and environ‐
1139 ment munging before calling _pydeps (so that function has a
1140 clean execution path).
1141
1143 pydeps.pystdlib.pystdlib()
1144 Return a set of all module-names in the Python standard library.
1145
1147 class pydeps.render_context.Rankdir(value, names=None, *values, mod‐
1148 ule=None, qualname=None, type=None, start=1, boundary=None)
1149 Bases: Enum
1150
1151 BOTTOM_TOP = 'BT'
1152
1153 LEFT_RIGHT = 'LR'
1154
1155 RIGHT_LEFT = 'RL'
1156
1157 TOP_BOTTOM = 'TB'
1158
1159 reverse()
1160
1161 class pydeps.render_context.RenderBuffer(target, reverse=False,
1162 rankdir=Rankdir.TOP_BOTTOM, cluster=False, min_cluster_size=0,
1163 max_cluster_size=1, keep_target_cluster=False, collapse_target_clus‐
1164 ter=False, **kw)
1165 Bases: object
1166
1167 cluster_stats()
1168
1169 graph(**kw)
1170
1171 text()
1172
1173 triage_clusters()
1174
1175 write_node(n, **attrs)
1176
1177 write_rule(a, b, **attrs)
1178
1179 class pydeps.render_context.RenderContext(out=None, reverse=False,
1180 rankdir=Rankdir.TOP_BOTTOM)
1181 Bases: object
1182
1183 dedent(txt)
1184 Write txt dedented.
1185
1186 graph(**kw)
1187 Set up a graphviz graph context.
1188
1189 rule() Write indented rule.
1190
1191 text() Get value of output stream (StringIO).
1192
1193 write(txt)
1194 Write txt to file and output stream (StringIO).
1195
1196 write_attributes(attrs)
1197 Write comma separated attribute values (if exists).
1198
1199 write_node(a, **attrs)
1200 a [a1=x,a2=y];
1201
1202 write_rule(a, b, **attrs)
1203 a -> b [a1=x,a2=y];
1204
1205 writeln(txt)
1206 Write txt and add newline.
1207
1208 pydeps.render_context.to_unicode(s)
1209
1211 Abstracting the target for pydeps to work on.
1212
1213 class pydeps.target.Target(path)
1214 Bases: object
1215
1216 The compilation target.
1217
1218 chdir_work()
1219
1220 close()
1221 Clean up after ourselves.
1222
1223 get_package_root()
1224
1225 get_parents()
1226
1227 is_dir = False
1228
1229 is_module = False
1230
1231 is_pysource = False
1232
1233 • Index
1234
1235 • Module Index
1236
1237 • Search Page
1238
1241 2023 - 2023 Bjorn Pettersen
1242
1243
1244
1245
12461.12.17 Sep 07, 2023 PYDEPS(1)