[Distutils] Parsing setup()

Ian Bicking ianb at colorstudy.com
Mon Jun 4 19:59:56 CEST 2007

Rob wrote:
> Hi,
> I'm writing a dependency resolver and I need to parse the setup() function
> in setup.py files and get all the packages in the "install_requires =
> [...]" list.
> Reading setup.py and using regular expressions work ok but not 100% of
> the time because people pass a variable sometimes etc.
> Any hints on how I can go about parsing the setup function?

If you have a built egg (which you can do with python setup.py egg_info, 
without actually installing anything) you can read the requires.txt file 
with pkg_resources.

Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org
             | Write code, do good | http://topp.openplans.org/careers

More information about the Distutils-SIG mailing list