[Distutils] Specifying version information once

Ben Finney ben+python at benfinney.id.au
Wed May 20 05:57:09 CEST 2009

Jean-Paul Calderone <exarkun at divmod.com> writes:

> On Wed, 20 May 2009 10:17:31 +1000, Ben Finney <ben+python at benfinney.id.au> wrote:
> >Those breakages seem to be caused in part because the module
> >containing version information is doing too much.
> The only thing the version module does is define the version.  For example,
>  $ cat _version.py
>  # This is an auto-generated file. Use Epsilon/bin/release-divmod to update.
>  from twisted.python import versions
>  version = versions.Version(__name__[:__name__.rfind('.')], 0, 9, 33)
>  $
> Of course, the "too much" here is the use of a structured version
> object.

No, I would say “too much” here is importing a module not guaranteed to
be installed, for creating something as simple as a version. I'd prefer
the above to be::

  $ cat _version.py
  # This is an auto-generated file. Use magicbean to update.
  version = "0.9.33"

Anything that wants to have that structured into something more complex
than a delimited string can use the funky Version type; but this
particular module should import without any dependencies, for exactly
the reasons that started this thread.

> Doing anything simpler would be much like the approach Phillip's
> pointed out, to have a simple text file and parse its contents without
> getting Python involved at all.

I still like the approach of having it in a module that can be imported
to automatically have the name bound to an appropriate value.

 \     “If you pick up a starving dog and make him prosperous, he will |
  `\      not bite you. This is the principal difference between a dog |
_o__)                    and a man.” —Mark Twain, _Pudd'n'head Wilson_ |
Ben Finney

More information about the Distutils-SIG mailing list