scripts: Add some tooling to build/install PyQt wheels
This commit is contained in:
parent
d5c9c41019
commit
a264c25314
|
|
@ -44,3 +44,4 @@ TODO
|
|||
/doc/extapi/_build
|
||||
/misc/nsis/include
|
||||
/misc/nsis/plugins
|
||||
/wheels
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/env python3
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2020 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 <http://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 main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('qt_location', help='Qt compiler directory')
|
||||
parser.add_argument('--wheels-dir', help='Directory to use for wheels')
|
||||
args = parser.parse_args()
|
||||
|
||||
old_cwd = pathlib.Path.cwd()
|
||||
|
||||
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])
|
||||
bin_path = pathlib.Path(sys.executable).parent
|
||||
subprocess.run([str(bin_path / 'pyqt-bundle'),
|
||||
'--qt-dir', args.qt_location, 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()
|
||||
|
|
@ -52,9 +52,12 @@ def parse_args() -> argparse.Namespace:
|
|||
default='auto',
|
||||
help="PyQt version to install.")
|
||||
parser.add_argument('--pyqt-type',
|
||||
choices=['binary', 'source', 'link', 'skip'],
|
||||
choices=['binary', 'source', 'link', 'wheels', 'skip'],
|
||||
default='binary',
|
||||
help="How to install PyQt/Qt.")
|
||||
parser.add_argument('--pyqt-wheels-dir',
|
||||
default='wheels',
|
||||
help="Directory to get PyQt wheels from.")
|
||||
parser.add_argument('--virtualenv',
|
||||
action='store_true',
|
||||
help="Use virtualenv instead of venv.")
|
||||
|
|
@ -207,6 +210,14 @@ def install_pyqt_link(venv_dir: pathlib.Path) -> None:
|
|||
link_pyqt.link_pyqt(sys.executable, lib_path)
|
||||
|
||||
|
||||
def install_pyqt_wheels(venv_dir: pathlib.Path,
|
||||
wheels_dir: pathlib.Path) -> None:
|
||||
"""Install PyQt from the wheels/ directory."""
|
||||
utils.print_title("Installing PyQt wheels")
|
||||
wheels = [str(wheel) for wheel in wheels_dir.glob('*.whl')]
|
||||
pip_install(venv_dir, *wheels)
|
||||
|
||||
|
||||
def install_requirements(venv_dir: pathlib.Path) -> None:
|
||||
"""Install qutebrowser's requirement.txt."""
|
||||
utils.print_title("Installing other qutebrowser dependencies")
|
||||
|
|
@ -247,6 +258,7 @@ def main() -> None:
|
|||
"""Install qutebrowser in a virtualenv.."""
|
||||
args = parse_args()
|
||||
venv_dir = pathlib.Path(args.venv_dir)
|
||||
wheels_dir = pathlib.Path(args.pyqt_wheels_dir)
|
||||
utils.change_cwd()
|
||||
|
||||
if args.tox_error:
|
||||
|
|
@ -270,6 +282,8 @@ def main() -> None:
|
|||
install_pyqt_source(venv_dir, args.pyqt_version)
|
||||
elif args.pyqt_type == 'link':
|
||||
install_pyqt_link(venv_dir)
|
||||
elif args.pyqt_type == 'wheels':
|
||||
install_pyqt_wheels(venv_dir, wheels_dir)
|
||||
elif args.pyqt_type == 'skip':
|
||||
pass
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in New Issue