On Fri, Jul 10, 2009 at 10:19:56AM -0400, Gary Poster wrote: > > On Jul 10, 2009, at 9:24 AM, Barry Warsaw wrote: > >> On Jul 10, 2009, at 8:58 AM, Marius Gedminas wrote: >> >>> What do people use to avoid repeating the version number both in the >>> setup.py as well as in application/library code, when the >>> application/library wants to know its own version number? >>> >>> I've seen several options: >>> >>> 1) put __version__ = '4.2' in yourpackage/__init__.py, have setup.py >>> do from yourpackage import __version__ and pass that to setup() >> >> This is generally what I do and it seems to work pretty well for me. I >> remember talking with Gary Poster about some problems with this, >> related to our open source lazr packages, but I don't recall the >> details. > > Basically, this means that your setup.py has to be able to import your > package's __init__.py without any of the dependencies. > > If your __init__.py only has a __version__ then this is fine. However, > if you want your __init__ to reexport something to avoid clients having > to do foo.foo.Foo-style imports from your package, or if you want to put > any other code in your __init__ that might need dependencies, this > breaks.
My __init__.py does "from _version import version as __version__" to solve this problem, setup.py then imports _version. Regards Floris -- Debian GNU/Linux -- The Power of Freedom www.debian.org | www.gnu.org | www.kernel.org _______________________________________________ Distutils-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/distutils-sig
