File: numpy_substvars.py

package info (click to toggle)
numpy 1%3A2.3.5%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 86,232 kB
  • sloc: python: 255,841; asm: 232,483; ansic: 212,578; cpp: 157,469; f90: 1,575; sh: 845; fortran: 567; makefile: 431; sed: 139; xml: 109; java: 97; perl: 82; cs: 62; javascript: 53; objc: 33; lex: 13; yacc: 9
file content (33 lines) | stat: -rw-r--r-- 1,295 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python3

'''
Check if debian/versions is sane and generate substvars for numpy:Provides.
'''

import os
import re

def main():
    meson_build = 'numpy/_core/meson.build'
    data = {}
    with open(meson_build) as file:
        for line in file:
            line = line.strip()
            mo = re.match("(?i)^(C_ABI_VERSION|C_API_VERSION) *= *'(0x[0-9A-F]+)'", line)
            if mo:
                data[mo.group(1)] = int(mo.group(2), base=16)
                if "C_ABI_VERSION" in data and "C_API_VERSION" in data:
                    break
    with open('debian/versions') as file:
        for line in file:
            line = line.strip()
            if not line or line.startswith('#'):
                continue
            key, value = line.split(None, 1)
            data[key] = value
    assert data['abi'] == str(data['C_ABI_VERSION'] - 0x2000000), f"ABI version mismatch, update debian/versions; debian={data['abi']} vs numpy={str(data['C_ABI_VERSION'] - 0x2000000)}"
    assert data['api'] == str(data['C_API_VERSION']), f"API version mismatch, update debian/versions; debian={data['api']} vs numpy={str(data['C_API_VERSION'])}"
    print('numpy3:Provides=python3-numpy2-abi%s, python3-numpy-api%s' % (data['abi'], data['api']))

if __name__ == '__main__':
    main()