Dear python enthusiasts,

For some industrial project a few years ago we needed a reliable way to get the 
version number for a package or module.
I found out that there was actually no method working in all edge cases, 
including:


  *   Built-in modules
  *   Unzipped wheels and eggs added to the python patch
  *   Non-installed project under development with version control information 
available
  *   Packages both installed and added to the python path (typically a 
developer working on a new version)

So I created one, and finally found the time to publish it.
No rocket science here, but you may find this new package useful: 
https://smarie.github.io/python-getversion/

It works with any imported module for now, including submodules.
Along with the version you get details about why a given version number is 
returned (is it because of the __version__ attribute that was found, or because 
of the Version metadata in the installed package, etc.)
Also, if one edge case is missing, it is fairly easy to add it.

If I missed something in the stdlib (I acme across the importlib.metadata 
initiative but as of now it does not seem to cover all of the above cases), 
please let me know so that I can cite it in the documentation and even redirect 
to it if it happens to already cover all the cases.

Happy summer to all !
--
Sylvain
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/OEXCPM45R2YBE5GBVRXK54CZGZFSBNDI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to