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
|
#!/usr/bin/env python3
# Copyright 2020-2021 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
#
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <https://www.gnu.org/licenses/>.
"""Build updated PyQt wheels."""
import os
import subprocess
import argparse
import sys
import pathlib
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
os.pardir))
from scripts import utils
def find_pyqt_bundle():
"""Try to find the pyqt-bundle executable next to the current Python.
We do this instead of using $PATH so that the script can be used via
.venv/bin/python.
"""
bin_path = pathlib.Path(sys.executable).parent
path = bin_path / 'pyqt-bundle'
if not path.exists():
raise FileNotFoundError("Can't find pyqt-bundle at {}".format(path))
return path
def main():
parser = argparse.ArgumentParser()
parser.add_argument('qt_location', help='Qt compiler directory')
parser.add_argument('--wheels-dir', help='Directory to use for wheels',
default='wheels')
args = parser.parse_args()
old_cwd = pathlib.Path.cwd()
try:
pyqt_bundle = find_pyqt_bundle()
except FileNotFoundError as e:
utils.print_error(str(e))
sys.exit(1)
qt_dir = pathlib.Path(args.qt_location)
bin_dir = qt_dir / 'bin'
if not bin_dir.exists():
utils.print_error("Can't find {}".format(bin_dir))
sys.exit(1)
wheels_dir = pathlib.Path(args.wheels_dir).resolve()
wheels_dir.mkdir(exist_ok=True)
if list(wheels_dir.glob('*')):
utils.print_col("Wheels directory is not empty, "
"unexpected behavior might occur!", 'yellow')
os.chdir(wheels_dir)
utils.print_title("Downloading wheels")
subprocess.run([sys.executable, '-m', 'pip', 'download',
'--no-deps', '--only-binary', 'PyQt5,PyQtWebEngine',
'PyQt5', 'PyQtWebEngine'], check=True)
utils.print_title("Patching wheels")
input_files = wheels_dir.glob('*.whl')
for wheel in input_files:
utils.print_subtitle(wheel.stem.split('-')[0])
subprocess.run([str(pyqt_bundle),
'--qt-dir', args.qt_location,
'--ignore-missing',
str(wheel)],
check=True)
wheel.unlink()
print("Done, output files:")
for wheel in wheels_dir.glob('*.whl'):
print(wheel.relative_to(old_cwd))
if __name__ == '__main__':
main()
|