download wheels using rules_python

This commit is contained in:
Damien Elmes 2021-10-15 15:50:47 +10:00
parent 819ec40a3e
commit 4a8e2bdc2d
6 changed files with 13 additions and 27 deletions

View file

@ -7,9 +7,9 @@ load("//proto:protobuf.bzl", "setup_protobuf_binary")
load("//proto:format.bzl", "setup_clang_format")
load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")
load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories")
load("@com_github_ali5h_rules_pip//:defs.bzl", "pip_import")
load("//pip/pyqt5:defs.bzl", "install_pyqt5")
load("//pip/pyqt6:defs.bzl", "install_pyqt6")
load("@rules_python//python:pip.bzl", "pip_parse")
anki_version = "2.1.49"
@ -33,10 +33,10 @@ def setup_deps():
native.register_toolchains("@python//:python3_toolchain")
pip_import(
pip_parse(
name = "py_deps",
requirements = "@ankidesktop//pip:requirements.txt",
python_runtime = "@python//:python",
requirements_lock = "@ankidesktop//pip:requirements.txt",
python_interpreter_target = "@python//:python",
)
install_pyqt5(

View file

@ -1,10 +1,10 @@
"""Repo setup that can't happen until after defs.bzl:setup_deps() is run."""
load("@py_deps//:requirements.bzl", "pip_install")
load("@py_deps//:requirements.bzl", "install_deps")
load("@rules_rust//tools/rust_analyzer/raze:crates.bzl", "rules_rust_tools_rust_analyzer_fetch_remote_crates")
load("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl", "esbuild_repositories")
def setup_late_deps():
pip_install()
install_deps()
rules_rust_tools_rust_analyzer_fetch_remote_crates()
esbuild_repositories()

View file

@ -2,28 +2,14 @@ load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@py_deps//:requirements.bzl", "requirement")
def pip_binary(name, pkg = None):
"Expose a binary from pip as an executable for linting."
"Expose a binary from pip as an executable for linting. Does not work on Windows."
if not pkg:
pkg = name
binary_prefix = requirement(pkg).replace(":pkg", ":bin/" + name)
copy_file(
name = name + "_bin",
src = select({
"@platforms//os:windows": binary_prefix + ".exe",
"//conditions:default": binary_prefix,
}),
out = name + "_bin.py",
)
native.py_binary(
native.alias(
name = name,
srcs = [":" + name + "_bin.py"],
main = ":" + name + "_bin.py",
deps = [
requirement(pkg),
],
actual = requirement(pkg).replace(":pkg", ":rules_python_wheel_entry_point_" + name),
visibility = ["//visibility:public"],
tags = ["manual"],
)

View file

@ -17,7 +17,7 @@ def copy_folder(pkgname, path, outbase):
shutil.copytree(path, os.path.join(outbase, f"{stubname}-stubs"))
name_re = re.compile("__types_(.+?)_\d")
name_re = re.compile("__types_(.+?)$")
if __name__ == "__main__":
outbase = os.path.abspath(sys.argv[1])

View file

@ -31,7 +31,7 @@ if __name__ == "__main__":
# bazel passes in \\?\c:\... path; mypy can't handle it, so we
# strip off prefix
for entry in sys.path:
if "__mypy_" in entry:
if entry.endswith("__mypy"):
typeshed = f"{entry[4:]}\\mypy\\typeshed"
args.append("--custom-typeshed-dir")
args.append(typeshed)

View file

@ -39,7 +39,7 @@ if __name__ == "__main__":
# bazel passes in \\?\c:\... path; mypy can't handle it, so we
# strip off prefix
for entry in sys.path:
if "__mypy_" in entry:
if entry.endswith("__mypy"):
typeshed = entry[4:] + "\\mypy\\typeshed"
args.append("--custom-typeshed-dir")
args.append(typeshed)