From 53276b3044ea702e6dc16311ead34ead15451740 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 16 Dec 2020 11:36:42 +1000 Subject: [PATCH] symlink generated .py/.pyi into tree to fix Python code completion --- pylib/.gitignore | 3 --- pylib/anki/.gitignore | 1 - pylib/anki/BUILD.bazel | 14 ++++++++++---- pylib/anki/backend_pb2.pyi | 1 + pylib/anki/fluent_pb2.pyi | 1 + pylib/anki/hooks_gen.py | 1 + pylib/anki/rsbackend_gen.py | 1 + qt/BUILD.bazel | 6 +++--- qt/aqt/BUILD.bazel | 19 ++++++++++++------- qt/aqt/hooks_gen.py | 1 + 10 files changed, 30 insertions(+), 18 deletions(-) delete mode 100644 pylib/anki/.gitignore create mode 120000 pylib/anki/backend_pb2.pyi create mode 120000 pylib/anki/fluent_pb2.pyi create mode 120000 pylib/anki/hooks_gen.py create mode 120000 pylib/anki/rsbackend_gen.py create mode 120000 qt/aqt/hooks_gen.py diff --git a/pylib/.gitignore b/pylib/.gitignore index 1596646cc..3dd6d9380 100644 --- a/pylib/.gitignore +++ b/pylib/.gitignore @@ -10,8 +10,5 @@ .pytype __pycache__ anki.egg-info -anki/backend_pb2.* -anki/fluent_pb2.* -anki/rsbackend_gen.py build dist diff --git a/pylib/anki/.gitignore b/pylib/anki/.gitignore deleted file mode 100644 index c1b440396..000000000 --- a/pylib/anki/.gitignore +++ /dev/null @@ -1 +0,0 @@ -buildinfo.py diff --git a/pylib/anki/BUILD.bazel b/pylib/anki/BUILD.bazel index f27719c66..525ec667c 100644 --- a/pylib/anki/BUILD.bazel +++ b/pylib/anki/BUILD.bazel @@ -65,11 +65,17 @@ alias( visibility = ["//visibility:public"], ) +_py_srcs = glob( + ["**/*.py"], + exclude = [ + "rsbackend_gen.py", + "hooks_gen.py", + ], +) + py_library( name = "anki", - srcs = glob([ - "**/*.py", - ]), + srcs = _py_srcs, data = [ "py.typed", ":backend_pb2", @@ -130,7 +136,7 @@ py_wheel( filegroup( name = "py_source_files", - srcs = glob(["**/*.py"]), + srcs = _py_srcs, visibility = [ "//pylib:__subpackages__", "//qt/po:__pkg__", diff --git a/pylib/anki/backend_pb2.pyi b/pylib/anki/backend_pb2.pyi new file mode 120000 index 000000000..d3937d76d --- /dev/null +++ b/pylib/anki/backend_pb2.pyi @@ -0,0 +1 @@ +../../bazel-bin/pylib/anki/backend_pb2.pyi \ No newline at end of file diff --git a/pylib/anki/fluent_pb2.pyi b/pylib/anki/fluent_pb2.pyi new file mode 120000 index 000000000..a8cb14b62 --- /dev/null +++ b/pylib/anki/fluent_pb2.pyi @@ -0,0 +1 @@ +../../bazel-bin/pylib/anki/fluent_pb2.pyi \ No newline at end of file diff --git a/pylib/anki/hooks_gen.py b/pylib/anki/hooks_gen.py new file mode 120000 index 000000000..66a6b1bd2 --- /dev/null +++ b/pylib/anki/hooks_gen.py @@ -0,0 +1 @@ +../../bazel-bin/pylib/anki/hooks_gen.py \ No newline at end of file diff --git a/pylib/anki/rsbackend_gen.py b/pylib/anki/rsbackend_gen.py new file mode 120000 index 000000000..b247575fd --- /dev/null +++ b/pylib/anki/rsbackend_gen.py @@ -0,0 +1 @@ +../../bazel-bin/pylib/anki/rsbackend_gen.py \ No newline at end of file diff --git a/qt/BUILD.bazel b/qt/BUILD.bazel index a526dc263..e9900f562 100644 --- a/qt/BUILD.bazel +++ b/qt/BUILD.bazel @@ -83,9 +83,9 @@ py_test( py_test( name = "format_check", - srcs = glob([ - "**/*.py", - ]), + srcs = glob(["**/*.py"]) + [ + "//qt/aqt:py_source_files", + ], args = [ "$(location .isort.cfg)", ], diff --git a/qt/aqt/BUILD.bazel b/qt/aqt/BUILD.bazel index 1d3347880..fadde7a2e 100644 --- a/qt/aqt/BUILD.bazel +++ b/qt/aqt/BUILD.bazel @@ -23,9 +23,14 @@ genrule( ], ) -aqt_srcs = glob([ - "**/*.py", -]) + [ +_py_srcs = glob( + [ + "**/*.py", + ], + exclude = ["hooks_gen.py"], +) + +_py_srcs_and_forms = _py_srcs + [ "//qt/aqt/forms:forms", "//qt/aqt/forms:icons", ] @@ -59,7 +64,7 @@ aqt_deps = [ # library without web/i18n data; faster for testing py_library( name = "aqt_without_data", - srcs = aqt_srcs, + srcs = _py_srcs_and_forms, data = aqt_core_data, visibility = ["//visibility:public"], deps = aqt_deps, @@ -67,7 +72,7 @@ py_library( py_library( name = "aqt_with_data", - srcs = aqt_srcs, + srcs = _py_srcs_and_forms, data = aqt_core_data + ["//qt/aqt/data"], visibility = ["//visibility:public"], deps = aqt_deps, @@ -122,8 +127,8 @@ py_wheel( filegroup( name = "py_source_files", - srcs = glob(["**/*.py"]), + srcs = _py_srcs, visibility = [ - "//qt/po:__pkg__", + "//qt:__subpackages__", ], ) diff --git a/qt/aqt/hooks_gen.py b/qt/aqt/hooks_gen.py new file mode 120000 index 000000000..ec787bc5a --- /dev/null +++ b/qt/aqt/hooks_gen.py @@ -0,0 +1 @@ +../../bazel-bin/qt/aqt/hooks_gen.py \ No newline at end of file