Search code examples
pythonpython-wheel

Python How can I get the version number from a .whl file


Because of some custom logging I would like to get the version number from a wheel file.

I could of course just parse the filename, but my guess is there would be a better way to do this.


Solution

  • You can also use pkginfo e.g.

    from pkginfo import Wheel
    
    w = Wheel(r'C:\path\to\package.whl')
    
    print(w.version)