supported_wheels.py 1006 Bytes
Newer Older
1
2
3
4
5
6
#!/usr/bin/env python
"""  Filter out wheel filenames not supported on this platform
"""
from __future__ import print_function

import sys
7
from os.path import basename
8

9
10
from packaging.tags import sys_tags

11
try:
12
    from wheel.install import WHEEL_INFO_RE as wheel_matcher
13
except ImportError:  # As of Wheel 0.32.0
14
    from wheel.wheelfile import WHEEL_INFO_RE
15
    wheel_matcher = WHEEL_INFO_RE.match
16
17


18
19
def tags_for(fname):
    # Copied from WheelFile code
20
    parsed_filename = wheel_matcher(basename(fname))
21
22
23
24
25
26
27
    tags = parsed_filename.groupdict()
    for pyver in tags['pyver'].split('.'):
        for abi in tags['abi'].split('.'):
            for plat in tags['plat'].split('.'):
                yield (pyver, abi, plat)


28
def main():
Christian Clauss's avatar
Christian Clauss committed
29
30
    supported = {
        (tag.interpreter, tag.abi, tag.platform) for tag in sys_tags()
31
    }
32
    for fname in sys.argv[1:]:
33
        tags = set(tags_for(fname))
34
35
36
        if supported.intersection(tags):
            print(fname)

Christian Clauss's avatar
Christian Clauss committed
37

38
39
if __name__ == '__main__':
    main()