Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 323
Johan Vergeer Avatar asked Feb 03 '17 07:02

Johan Vergeer


People also ask

How do I read a WHL file in Python?

whl file can be extracted using unzip or by right clicking on the file and extracting using the Extract Here graphical interface in Ubuntu/Debian systems. After extracting, one can inspect the source code of . py files and the contents of metadata files which will be located in library-name-with-version.

How do I get version number from setup py?

Store version string for use during install You could make a version.py in your package with a __version__ line, then read it from setup.py using execfile('mypackage/version.py') , so that it sets __version__ in the setup.py namespace.

What is .WHL file in Python?

A Python . whl file is essentially a ZIP ( . zip ) archive with a specially crafted filename that tells installers what Python versions and platforms the wheel will support. A wheel is a type of built distribution.


1 Answers

You can also use pkginfo e.g.

from pkginfo import Wheel

w = Wheel(r'C:\path\to\package.whl')

print(w.version)
like image 54
Pakman Avatar answered Sep 21 '22 07:09

Pakman