On Fri, Jan 29, 2010 at 10:29 PM, Lennart Regebro <rege...@gmail.com> wrote: > On Fri, Jan 29, 2010 at 22:27, Tarek Ziadé <ziade.ta...@gmail.com> wrote: >> On Fri, Jan 29, 2010 at 10:05 PM, Barry Warsaw <ba...@python.org> wrote: >> [..] >>> However, it would be nice if setuptools/distribute supported something like >>> this out of the box. The important thing is to have exactly one place to >>> set >>> the package's version number. >> >> For metadata fields like "version", one option I am working on in >> Distutils itself is to have a complementary section in the static >> setup.cfg file, where you can set some fields: >> >> [setup] >> name=foo >> version=1.9.8 >> >> Once setup() is run, the Distribution class will look at this file, to >> complete the options provided by code; >> >> Of course this supposes that the version is not calculated by some >> code (like in your solution). But I think a plain, non-development >> version, can be static. > > What you want is then a simple way of getting this version number into > the python code. Any recommendations for that?
It depends on what code. Let's say that we want to have one and only one place for the "version" value. There are two type of code in a Distutils-based project. The one that is used in setup.py to create distribution, compile extensions (I'll call it the "build code"), and the one that is installed on the target system. For the build code, if Distutils has the capability to get metadata from setup.cfg, then it would be just a matter of publishing an API for getting it as well in there. Now, if the project is installed, setup.[py/cfg] are gone, and the only place where the version is located is the PKG-INFO file. Distribute/Setuptools provides and APIs to read this PKG-INFO file and get it already. IOW, in the packages and modules of the project, this API can be used. The only concern I have is that the development mode (e.g. getting the version in the packages and modules of the project when it's not installed) supposes that the "develop" command was called (so that the PKG-INFO file is locally available). But I would definitely completely isolate setup.py code from the project' packages/modules to avoid problems. Tarek _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig