Hi,
Le 07/04/2011 13:10, Michael Foord a écrit :
On 4/5/2011 11:52 AM, Barry Warsaw wrote:
__version__ =
pkgutil.get_distribution('elle').metadata['version']
I really dislike this way of specifying the version. For a start it
is
really ugly.
More importantly it means the version information is *only* available
if
the package has been installed by "packaging", and so isn't available
for the parts of my pre-build process like building the documentation
(which import the version number to put into the docs).
Currently all my packages have the canonical version number
information
in the package itself using:
__version__ = '1.2.3'
Anything that needs the version number, including setup.py for upload
to
pypi, has one place to look for it and it doesn't depend on any other
tools or processes. If switching to "packaging" prevents me from
doing
this then it will inhibit me using "packaging".
This is similar to my own comment on distutils-sig:
One of the main complaint against setuptools is that having to change
your application code because of the packaging tool used was not a
good
idea. Having to use require instead of import or resource_whatever
instead of open (or get_data, the most sadly underused function in
the
stdlib) because you use setuptools instead of distutils was a bad
thing.
As stated in the PEP, having a __version__ attribute in the module is
common, so my opinion is that making the packaging tool use that info
is
the Right Thing™, and having the dependency in the reverse sense is
wrong. I don’t see a problem with having harmless duplication in the
*installed* system, once in elle.__version__ and once in the pkgutil
metadata database.
Barry’s reply:
I'm including this section because at Pycon, some people did express
an
interest in deriving the version number in this direction. I wanted
to
capture what that might look like. Since this is an informational
PEP, I
think it makes sense to include alternative approaches, but I tend to
agree
with you that it will be much more common to define
module.__version__ and
derive the metadata from that.
IOW, you can define the version only once, either in your source file
or
in the setup.cfg file, and the PEP describes how to get that info from
the other place. My personal opinion is that the approach using
pkgutil.get_distribution should be much less prominent than the one
putting the version in the Python code.
Regards
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com