Debian Codegraph @

debian/scripts/verify-all-headers-present.py

raw symbols SCIP
1 #!/usr/bin/python3
2
3 # Some headers are generated at build time, so we ship them in pypy3 (anch-dep).
4 # Others are static and shipped in pypy3-dev (arch-indep).
5 # Because we are cherry-picking them from different places, verify that all the
6 # expected headers have been shipped.
7
8 import sys
9 from glob import glob
10 from os import listdir
11 from os.path import basename
12
13
14 def installed_headers(binpkg):
15 path = f'debian/{binpkg}.install'
16 with open(path, encoding='utf-8') as f:
17 for line in f:
18 if line.startswith('#'):
19 continue
20 parts = line.split()
21 if len(parts) == 2:
22 pattern, dest = parts
23 elif len(parts) == 3 and parts[1] == '=>':
24 pattern, _, dest = parts
25 else:
26 print(f'Failure to parse {path}: {line}')
27 sys.exit(1)
28 if dest.rstrip('/') == '/usr/include/pypy3.11':
29 for fn in glob(pattern):
30 yield basename(fn)
31
32
33 installed = (
34 set(installed_headers('pypy3-dev'))
35 | set(installed_headers('pypy3')))
36 built_headers = set(
37 basename(fn) for fn in listdir('include/pypy3.11')
38 if fn.endswith('.h'))
39
40 if installed != built_headers:
41 if built_headers - installed:
42 print("Missing headers:", built_headers - installed)
43 if installed - built_headers:
44 print("Extra headers:", installed - built_headers)
45 sys.exit(1)