-
Notifications
You must be signed in to change notification settings - Fork 15
/
quick-test
executable file
·115 lines (96 loc) · 2.79 KB
/
quick-test
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import os.path
from typing import NoReturn
PROG = '''\
inst() {{
dpkg -i "/dist/$1"_*.deb || true
DEBIAN_FRONTEND=noninteractive apt-get install -qq -yf
dpkg -l | grep "$1"
}}
. /etc/lsb-release
apt-get update -qq
if {lt312}; then
inst libpython{ver}-minimal
fi
inst libpython{ver}-stdlib
inst libpython{ver}
if {lt312}; then
inst python{ver}-minimal
fi
inst python{ver}
python{ver} -c 'import cmath, ssl'
if {lt312}; then
# distutils.__init__ and distutils.version should be in main lib package
python{ver} -c 'import distutils; assert distutils.__file__'
python{ver} -c 'import distutils.version'
fi
apt-get install -y --no-install-recommends ca-certificates
if [ \
"$DISTRIB_CODENAME" = focal -a {ver} = '3.9' -o \
"$DISTRIB_CODENAME" = jammy -a {ver} = '3.11' \
]; then
apt-get install -y --no-install-recommends python3-distutils
else
if {lt313}; then
inst python{ver}-lib2to3
fi
if {lt312}; then
inst python{ver}-distutils
fi
fi
# make sure get-pip.py works
python{ver} -c '
import urllib.request
exec(urllib.request.urlopen("https://bootstrap.pypa.io/get-pip.py").read())
'
test -x /usr/local/bin/pip
python{ver} -m pip --version
/usr/local/bin/pip install astpretty
test -x /usr/local/bin/astpretty
cd /tmp
python{ver} -c '
import shutil
import urllib.request
resp = urllib.request.urlopen("https://bootstrap.pypa.io/virtualenv.pyz")
with open("virtualenv.pyz", "wb") as f:
shutil.copyfileobj(resp, f)
'
python{ver} virtualenv.pyz venv
test -x venv/bin/pip
test -d venv/lib/python{ver}/site-packages
venv/bin/pip install astpretty
test -x venv/bin/astpretty
'''
def bool_prog(b: bool) -> str:
return str(b).lower()
def main() -> NoReturn:
parser = argparse.ArgumentParser()
parser.add_argument('--distrib-codename', default='jammy')
parser.add_argument('--dist-dir', default='../dist')
parser.add_argument('--src-dir', default='.')
args = parser.parse_args()
with open(os.path.join(args.src_dir, 'debian/rules')) as f:
for line in f:
if line.startswith('VER='):
_, version = line.strip().split('=')
break
else:
raise AssertionError('could not find version!')
major_s, minor_s = version.split('.')
major, minor = int(major_s), int(minor_s)
cmd = (
'docker', 'run', '--rm',
'-v', f'{os.path.abspath(args.dist_dir)}:/dist:ro',
f'ubuntu:{args.distrib_codename}',
'bash', '-euxc',
PROG.format(
ver=version,
lt312=bool_prog((major, minor) < (3, 12)),
lt313=bool_prog((major, minor) < (3, 13)),
),
)
os.execvp(cmd[0], cmd)
if __name__ == '__main__':
raise SystemExit(main())