[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-distutils-sig
Subject:    Re: [Distutils] 2to3 and version numbers with distribute
From:       Andrew McNabb <amcnabb () mcnabbs ! org>
Date:       2012-02-08 22:16:24
Message-ID: 20120208221624.GD18178 () mcnabbs ! org
[Download RAW message or body]

On Wed, Feb 08, 2012 at 04:45:33PM -0500, Barry Warsaw wrote:
> 
> Take a look at informational PEP 396 for some thoughts:
> 
> http://www.python.org/dev/peps/pep-0396/

That was a very interesting read.  If distribute provided a get_version
function as described in the PEP, I would be very excited.  It's a
little obnoxious to include a custom function, although the example from
setup_helpers.py that you provided doesn't look too bad.  Are there any
plans to include some sort of robust get_version function in distribute
and distutils2?


> I'll also mention that depending on the minimum version of Python you need to
> support, you might be able to do away with 2to3 and support both Python 2 and
> 3 from the same code base.  This is what I'm doing whenever possible (with
> Python 2.6 as a minimum version), and it's not too hard to do.  Michael Foord
> has some good recommendations for writing code compatible even back to 2.4.

I've actually taken this approach for two or three projects in the past,
and it's worked out well for me.  With this particular project, I was
hoping to keep compatibility with 2.5, but I might consider limiting
support to 2.6.  Getting exception handling to work in both Python 2.5
and Python 3 is unacceptably ugly to me, though I'm impressed that it's
possible.


> If you can't do that, try to minimize the amount of code that "from xyz import
> version" has to execute.  Maybe stick an __version__ attribute in your
> xyz/__init__.py file, and nothing else.  Or put the version number in a
> version.txt file and read from that in both your xyz.version module and your
> setup.py.
> 
> Better yet, don't grab the version out of that module by importing.  Instead,
> just parse the contents of the file.  You might find the get_version()
> function from this little helper useful for that:
> 
> http://bazaar.launchpad.net/~barry/flufl.enum/trunk/view/head:/setup_helpers.py

Thanks for the comments.  You've given me some good ideas, though I'm
still a bit disappointed that there doesn't seem to be a standard
solution for this.

--
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55  8012 AB4D 6098 8826 6868
_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic