[Distutils] automating __version__' ing issues

Alexander Schmolck a.schmolck at gmx.net
Mon May 14 14:58:10 CEST 2007

"Phillip J. Eby" <pje at telecommunity.com> writes:

> At 01:09 AM 5/14/2007 +0100, Alexander Schmolck wrote:
>>"Phillip J. Eby" <pje at telecommunity.com> writes:
>> >>Here's the rub-- it must be in setup.py and you probably want
>> >>to give your package access to it so that it can be reported. It
>> >>appears that the current idiom for solving this dilemma is to but a
>> >>release.py or version.py file in your package, which is sucked up into
>> >>the setup.py file with execfile (see
>> >><http://kid-templating.org/trac/browser/trunk/setup.py> for an
>> >>example). You then manually maintain the version number in one place
>> >>(the release.py file).
>> >
>> > Yep, this is what most people do.
>>Is there a standard trick to get the desired svn-revision? Running
>>`'svnversion > __svn_version__.py`` in setup.py when a distrubtion-building
>>command is issued and then importing that in a hand-maintained
>>``version.py``/``release.py`` file should work, but is there a way to check
>>whether a setup.py command falls into a certain category?
> I don't understand what you're trying to do.  

I'd like to have a mechanism that has me specify two things in *one* central

1. A self-chosen version number, e.g. "1.1"
2. A release flag (e.g. official_release=False, meaning it's an official and
   not a development release)

Now in all other locations I'd like to get a version string that either is
"1.1" if release is True "1.1.dev43" (or whatever the svn revision) if release
is False. 

All other locations means at least setup.py and a __init__.py (via import or
execfile if needs be).

> Why do you need the SVN revision in a .py file?

I need it somewhere where it can be accessed by setup.py and the installed
package at a negligible cost. Using some convoluted invocation to create a
__svn_version__.py file in setup.py is the way numpy.distutils based project
do it, but I'd really like to avoid that (and numpy.distutils in general). 

>>This sounds more like it, but I don't assume this package is going to be ready
>>for an official release anytime soon?
> Nope, and it's not documented either.  I stole the idea, however, from another
> open source program that does something quite similar, but unfortunately I
> don't remember the name of that other program.

vertoo? Unfortunately that's alpha, too (and no releases since 2003).



p.s. I notice that a cc: or to: to your email address bounces -- is that
intended? (For what it's worth, I'd prefer if docutils-sig would just set the
reply to header to the list anyway -- it's what the scipy, numpy and many
other lists already do anyway and clearly the desired default behavior for the
vast majority of replies to messages on this or most technical lists; I guess
it might some unfortunate standard for the *-sig lists, though).

More information about the Distutils-SIG mailing list