[Distutils] Equivalent of config.h?

David Cournapeau cournape at gmail.com
Wed Jun 16 16:52:27 CEST 2010

On Wed, Jun 16, 2010 at 11:29 PM, Denis Jasselette <dionysos_13 at yahoo.fr> wrote:
> Éric Araujo wrote:
>> If your script has taken care of separating functions and the mail
>> call
>> in a “if __name__ == '__main__'” block, you can just import your
>> script
>> and get its __version__ attribute.
> It was my first guess but then, I would have to rename my script with
> a .py extension. Which is not great in an executable name.
> P.J. Eby wrote:
>> 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.
> It works. However, I'd rather not force users to install setuptools if
> possible.
> David Cournapeau wrote:
>> This is a perfectly fine solution. It is simple, and does not requires
>> any 3rd party code.
> It doesn't seem very clean though.

I guess it is a matter of opinion, but I  find it clearer than the
other suggested solutions.

> I have another problem with this solution. Distutils seems to set
> permissions of py_modules to non-world-readable. Meaning that, as I have
> to launch the installation as root, I can't read it unless I launch the
> script as root as well. The weird part is that the script's permissions
> are just fine.

What OS are you using and which set of commands did you exactly use ?


More information about the Distutils-SIG mailing list