list python package dependencies without loading them?

后端 未结 3 1548
天涯浪人
天涯浪人 2020-11-28 09:45

Say that python package A requires B, C and D; is there a way to list A → B C D without loading them ?
Requires in the metadata (yolk -M A

3条回答
  •  我在风中等你
    2020-11-28 10:02

    modulefinder from the standard lib

    New in version 2.3.

    This module provides a ModuleFinder class that can be used to determine the set of modules imported by a script. modulefinder.py can also be run as a script, giving the filename of a Python script as its argument, after which a report of the imported modules will be printed.

    I am not sure if it complies with your requierement about not loading the modules. From here:

    modulefinder use bytecode inspection to find dependencies, and therefore is free from any side-effects that may be caused by importing the modules being studied.

    Other hints about the use of pylint or Gui2exe here

提交回复
热议问题