con-f-use
(confus)
1
Given I have a PEP compliant filename of a source distribution or wheel, like in the examples below:
dummypkg-1.0.24+ga45fb6f.master-py3-none-any.whl
dummypkg-1.0.24+ga45fb6f.master-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
dummypkg-1.0.24.tar.gz
Is there an official tool or library to extract information from that filename like:
- Canonical package name (dummypkgs)
- Version (1.0.24)
- Local version (ga45fb6f.master)
- ABI
- Target Interpreters
- Platform
- a.s.o.
tiran
(Christian Heimes)
2
The packaging
package has everything you need to deal with packaging metadata:
>>> from packaging.utils import parse_wheel_filename
>>> parse_wheel_filename("dummypkg-1.0.24+ga45fb6f.master-py3-none-any.whl")
('dummypkg', <Version('1.0.24+ga45fb6f.master')>, (), frozenset({<py3-none-any @ 139823742779584>}))
>>> parse_wheel_filename("dummypkg-1.0.24+ga45fb6f.master-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl")
('dummypkg', <Version('1.0.24+ga45fb6f.master')>, (), frozenset({<pp310-pypy310_pp73-manylinux_2_17_x86_64 @ 139823742814592>, <pp310-pypy310_pp73-manylinux2014_x86_64 @ 139823742814656>}))
3 Likes