[Distutils] Equivalent of config.h?
dionysos_13 at yahoo.fr
Wed Jun 16 16:29:37 CEST 2010
Éric Araujo wrote:
> If your script has taken care of separating functions and the mail
> in a “if __name__ == '__main__'” block, you can just import your
> 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').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
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. But I suppose I could live with that.
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.
More information about the Distutils-SIG