通过分析python包的导入来探索其依赖关系。

pkgdeps的Python项目详细描述


通过分析python包的导入来探索其依赖关系。

这可能有助于:

  • 查看包中的模块如何相互依赖
  • 查看依赖哪些内置库
  • 第三方依赖关系分析

示例

探索此项目的依赖关系:

$ pkgdeps /path/to/pkgdeps
pkgdeps
  - argparse.ArgumentParser
  - ast
  - collections.defaultdict
  - functools.reduce
  - os
  - os.path
  - sys

限制

  • 仅针对Python3包使用Python3进行测试。
  • 不处理条件导入;检查所有条件分支。
  • 输出导入的模块成员:from os.path import join创建 依赖于os.path.join,但我们可能只想要os.path,例如。 tsort输出。但是,内部依赖关系被粗化为模块 水平。

安装

$ pip install pkgdeps

用法

有多种选项可用于筛选和格式化输出:

$ pkgdeps -h
usage: pkgdeps [-h] [-n <num>] [-m <num>] [-e <type> | -o <type>]
               [-f <format>]
               </path/to/package>

Explore dependencies of a package by parsing its imports.

positional arguments:
  </path/to/package>    path to package root

optional arguments:
  -h, --help            show this help message and exit
  -n <num>, --package-module-name-segments <num>
                        truncate module names of inspected package to given
                        number of segments (and consolidate imports)
  -m <num>, --dependency-module-name-segments <num>
                        truncate module names of dependencies to given number
                        of segments (and deduplicate)
  -e <type>, --exclude <type>
                        exclude various kinds of dependencies from output
                        (builtin, 3rd-party, internal)
  -o <type>, --only <type>
                        include only dependencies of the given type (builtin,
                        3rd-party, internal)
  -f <format>, --format <format>
                        graph output format (tree, tsort)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
安卓中的java标签长点击问题   JavaSpringMVC多行表单提交提交新的ModelAttribute   程序来查找java程序中的方法数   在JSF中自动选择java下拉列表   java onNext为ArrayList的每个元素触发,而不是使用RXJava触发一次   为什么java不允许创建内部类的实例?   JavaJSF<p:calendar>小部件在选择不同月份时不会刷新   java如何限制JFileChooser只允许选择特定数量的文件?   java ANT build无法识别geckodriver可执行文件“驱动程序可执行文件不存在”   java TextView空指针异常   java试图在安卓中传递参数   如何将XML配置转换为Java   java支持使用JAXRPC的soap服务,但pom中没有定义它。xml   在Java中检查整个ArrayList