Python package dependency list without downloading them?

Let's say that Python A package requires B, C, and D; is there any way to list A → BCD without loading them?
Requires in metadata ( yolk -MA ) are often incomplete, grr.
You can download A.tar / A.egg, then browse A / setup.py, but some of them are pretty hot.

(I would have thought that getting at least first-level dependencies could be mechanized; even a 98% solution would be better than downloading using avalanche access.)

Related question: pip-upgrade-package-without-upgrading-dependencies

+22
python dependencies packaging
May 20, '10 at 15:27
source share
3 answers

Snakefood

 sfood -fuq package.py | sfood-target-files 

will display the dependencies.

 `-f` tells sfood to follow dependencies recursively `-u` tells sfood to ignore unused imports `-q` tells sfood to be quiet about debugging information 

To filter modules from the standard library, you can use

 sfood -fuq package.py | sfood-filter-stdlib | sfood-target-files 

As you already noted, if there are other directories that you would like to ignore, you can also use the sfood -I flag.

+28
May 20 '10 at 15:59
source share

modulefinder from standard lib

New in version 2.3.

This module provides the ModuleFinder class, which can be used to determine the set of modules the script imports. modulefinder.py can also be run as a script, specifying the Python script file name as an argument, after which a report of the imported modules will be printed.

I'm not sure if this meets your requirements for not loading modules. From here :

modulefinder uses byte-code checking to find dependencies and, therefore, without any side effects that may be caused by the import of the modules being studied.

Other tips on using pylint or Gui2exe here

+13
May 20 '10 at 17:18
source share

If by package you mean the package installed on the pip (and not the directory with __init__.py), then you can use a Python package called pip. For example:

 def get_all_package_dependencies(): """Return dictionary of installed packages to list of package dependencies.""" return { dist.key: [r.key for r in dist.requires()] for dist in pip.get_installed_distributions() } 
+6
Aug 06 '13 at 9:18
source share



All Articles