[Distutils] Equivalent of config.h?

P.J. Eby pje at telecommunity.com
Wed Jun 16 01:43:41 CEST 2010


At 12:26 AM 6/16/2010 +0200, Denis Jasselette wrote:
>I am trying to distribute a
>script where I should be able to output the current version number.
>
>I thought that I could do things in an opposite way as in C. Rather than
>having the building system to create the config.h, I could import a
>config.py in my setup.py and distribute it as a py_module along with the
>script.
>
>Do you have better solutions?

Yes.  Use setuptools in your setup.py, and declare the version 
there.  Then, in your script, use:

    from pkg_resources import require
    my_version = require('MyProjectName')[0].version

Where 'MyProjectName' is whatever 'name=' argument you passed to 
setup() in your setup.py.



More information about the Distutils-SIG mailing list