From 36fdc607c674fc2d41b3a20ed77d1b42aa24aac5 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 5 Oct 2021 14:05:53 +1000 Subject: [PATCH] add run-qt5 script to run with 5.x --- qt/BUILD.bazel | 14 ++++++++++++++ qt/aqt/BUILD.bazel | 19 ++++++++++++++++--- run-qt5 | 24 ++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100755 run-qt5 diff --git a/qt/BUILD.bazel b/qt/BUILD.bazel index 93d5473b3..c07d8cec7 100644 --- a/qt/BUILD.bazel +++ b/qt/BUILD.bazel @@ -133,6 +133,20 @@ py_binary( ], ) +py_binary( + name = "runanki_qt5", + srcs = [ + "bazelfixes.py", + "runanki.py", + ], + imports = ["."], + main = "runanki.py", + deps = [ + "//pylib/anki", + "//qt/aqt:aqt_with_data_qt5", + ], +) + py_binary( name = "dmypy", srcs = [ diff --git a/qt/aqt/BUILD.bazel b/qt/aqt/BUILD.bazel index ad816a68b..788cae435 100644 --- a/qt/aqt/BUILD.bazel +++ b/qt/aqt/BUILD.bazel @@ -50,7 +50,6 @@ aqt_deps = [ requirement("waitress"), requirement("send2trash"), requirement("jsonschema"), - "@pyqt6//:pkg", ] + select({ "@bazel_tools//src/conditions:host_windows": [ requirement("psutil"), @@ -66,7 +65,9 @@ py_library( srcs = _py_srcs_and_forms, data = aqt_core_data, visibility = ["//visibility:public"], - deps = aqt_deps, + deps = aqt_deps + [ + "@pyqt6//:pkg", + ], ) py_library( @@ -74,7 +75,19 @@ py_library( srcs = _py_srcs_and_forms, data = aqt_core_data + ["//qt/aqt/data"], visibility = ["//visibility:public"], - deps = aqt_deps, + deps = aqt_deps + [ + "@pyqt6//:pkg", + ], +) + +py_library( + name = "aqt_with_data_qt5", + srcs = _py_srcs_and_forms, + data = aqt_core_data + ["//qt/aqt/data"], + visibility = ["//visibility:public"], + deps = aqt_deps + [ + "@pyqt5//:pkg", + ], ) py_package( diff --git a/run-qt5 b/run-qt5 new file mode 100755 index 000000000..9fd6ef056 --- /dev/null +++ b/run-qt5 @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +run_linux() { + bazel run $BUILDARGS //qt:runanki_qt5 -- $* +} + +run_mac() { + # QtWebEngineProcess is unable to locate icudtl.dat from a symlinked tree, + # so we need to copy the files into a working folder before running on a Mac. + workspace=$(dirname $0) + bazel build $BUILDARGS //qt:runanki_qt5 && \ + rsync -aiL --exclude=anki/external --delete -f'-p __pycache__' \ + $workspace/bazel-bin/qt/runanki* $workspace/bazel-copy/ && \ + $workspace/bazel-copy/runanki_qt5 $* +} + +export PYTHONWARNINGS=default +if [[ "$OSTYPE" == "darwin"* ]]; then + run_mac $* +else + run_linux $* +fi