I've already asked on python-ideas, but it was suggested that as there's a
PEP already, it's time to move this along. So here's the pitch.

Over the years, I've seen __version__ used very broadly but not *quite* in
all packages. I've always known it was a convention, not a requirement. But
it turns out it's not even a "official" convention.

But it really would be nice if there was a consistent way that I could
count on to get the version of a package at run time from the package
itself.

Turns out this was suggested in PEP 396 -- and deferred almost 13 years ago!

https://www.python.org/dev/peps/pep-0396/

In the status note, it says:

"""
Further exploration of the concepts covered in this PEP has been deferred
for lack of a current champion interested in promoting the goals of the PEP
and collecting and incorporating feedback, and with sufficient available
time to do so effectively.
"""

Well, I may be willing to be that champion, if a core dev is willing to
sponsor.

And, well, after 13 years, we've seen __version__ be very broadly, though
certainly not universally used.

Honestly, I haven't looked to see to what extent setuptools supports it,
but will, of course, do so if folks think this is worth pursuing. And the
PyPA has moved toward "distribution" meta data, preliminarily supported by
importlib.metadata.version.

So  maybe this is a settled issue, and we just need to change the status of
the PEP.

But for my part, I FAR prefer the version info to be embedded in the code
of the package in a simple way, rather than hiding among the metadata, and
requiring importlib.metadata.version to get a version at runtime.

I note that PEP8 uses __version__ as an example of a "module level dunder"
-- but only suggests where it should be put, not how it be used :-)

Of course, there will be a need to update the PEP to match current
practice, and if it is me doing it, I'd make it very simple

So what do you'all think? After thirteen years, it would be nice to put
this to bed.

I think the next step is to see if I can find a sponsor :-)

-CHB


-- 
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/EY44EMZ2R4RUMUUIVEFFVOXM2H3L427Z/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to