load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load("@rules_python//python:defs.bzl", "py_library") load("@py_deps//:requirements.bzl", "requirement") load("@rules_python//experimental/python:wheel.bzl", "py_package", "py_wheel") load("//:defs.bzl", "anki_version") genrule( name = "hooks_gen", outs = ["hooks_gen.py"], cmd = "$(location //qt:genhooks_gui) $@", tools = ["//qt:genhooks_gui"], ) genrule( name = "extract_sass_colors", srcs = [ "//ts/sass:_vars.scss", ], outs = ["colors.py"], cmd = "$(location //qt:extract_sass_colors) $< $@", tools = [ "//qt:extract_sass_colors", ], ) aqt_srcs = glob([ "**/*.py", ]) + [ "//qt/aqt/forms:forms", "//qt/aqt/forms:icons", ] aqt_core_data = [ "colors.py", "py.typed", ":hooks_gen", ] aqt_deps = [ requirement("protobuf"), requirement("decorator"), requirement("requests"), requirement("beautifulsoup4"), requirement("flask"), requirement("flask-cors"), requirement("waitress"), requirement("send2trash"), requirement("markdown"), requirement("jsonschema"), "@pyqt5//:pkg", ] + select({ "@bazel_tools//src/conditions:host_windows": [ requirement("psutil"), requirement("pywin32"), ], "//conditions:default": [], }) # library without web/i18n data; faster for testing py_library( name = "aqt_without_data", srcs = aqt_srcs, data = aqt_core_data, visibility = ["//visibility:public"], deps = aqt_deps, ) py_library( name = "aqt_with_data", srcs = aqt_srcs, data = aqt_core_data + ["//qt/aqt/data"], visibility = ["//visibility:public"], deps = aqt_deps, ) py_package( name = "aqt_pkg", packages = [ "qt.aqt", ], deps = [ ":aqt_with_data", ], ) py_wheel( name = "wheel", description_file = "wheel_description.txt", distribution = "aqt", homepage = "https://apps.ankiweb.net", license = "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", python_tag = "py3", python_version = ">=3.8", requires = [ # "pyaudio", # currently off as a pain to install on Windows for code completion "beautifulsoup4", "requests", "send2trash", "markdown", "jsonschema", "flask", "flask_cors", "waitress", "pyqt5>=5.12", "pyqtwebengine", 'psutil; sys.platform == "win32"', 'pywin32; sys.platform == "win32"', "anki==" + anki_version, ], strip_path_prefixes = [ "qt", ], version = anki_version, deps = [ ":aqt_pkg", ], ) filegroup( name = "py_source_files", srcs = glob(["**/*.py"]), visibility = [ "//qt/po:__pkg__", ], )