Extracting python dependencies automatically

Toshio Kuratomi a.badger at gmail.com
Wed Aug 15 22:14:14 UTC 2007


On 8/15/07, Panu Matilainen <pmatilai at redhat.com> wrote:
> For provides, look into site-packages and turn the dir/filenames found
> into foo.bar type entries in python() namespace, for example:
> [pmatilai at localhost ~]$ rpm -ql yum-metadata-parser|./pythondeps.py -P
> python(_sqlitecache)
> python(sqlitecachec)
>
> For requires, try to locate any python scripts and modules and for each
> found, run them through python's modulefinder which attempts to figure out
> which modules a script/module uses. Then, based on the filenames gotten
> from modulefinder results, turn them into python(<name>) entries, for
> example:
> [pmatilai at localhost ~]$ rpm -ql createrepo|./pythondeps.py -R
> python(_sqlitecache)
> python(abi) = 2.5
> python(libxml2)
> python(libxml2mod)
> python(rpm._rpmmodule)
> python(sqlitecachec)
>
> Haven't tested it at all thoroughly, but visual inspection of what I've
> tried would appear to be reasonably sane. That said I'm often blind as a
> bat so there might be severe problems there and I just didn't notice :)
>
> If any python-heads are interested in playing around / testing /
> improving, here's the initial attempt:
> http://laiskiainen.org/rpm/scripts/pythondeps.py
>
> Thoughts / comments?

Some python modules have started to use eggs from setuptools.  These
can have dependency information that includes versions.

Look at /usr/lib/python2.5/site-packages/TurboGears-1.0.2.2-py2.5.egg-info/requires.txt

for an example.

Also, we probably want the ability to ship zipped eggs, not just
unzipped eggs at some point (to support installing multiple versions
of a module.)

egg documentation:
  http://peak.telecommunity.com/DevCenter/PythonEggs

-Toshio




More information about the devel mailing list