From 29466f6be11ee56b751c1e82613bfc61a4d76caa Mon Sep 17 00:00:00 2001 From: Andreas Berthoud Date: Sun, 6 Jun 2021 11:21:09 +0200 Subject: [PATCH] Add python_toolchain --- .bazelrc | 1 - BUILD | 23 ++++++++++++++++++++++- WORKSPACE | 4 +++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index f0f013d..e69de29 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1 +0,0 @@ -run --incompatible_use_python_toolchains=false --python_top=//:python38 diff --git a/BUILD b/BUILD index b19861b..6b7fba8 100644 --- a/BUILD +++ b/BUILD @@ -1,9 +1,30 @@ load("@rules_python//python:defs.bzl", "py_binary") -load("@my_deps//:requirements.bzl", "requirement") +load("@rules_python//python:defs.bzl", "py_runtime_pair") +load("@pip_requirements//:requirements.bzl", "requirement") + +py_runtime( + name = "python37", + interpreter_path = "/usr/local/bin/python3.7", + python_version = "PY3" +) py_runtime( name = "python38", interpreter_path = "/usr/local/bin/python3.8", + python_version = "PY3" +) + +py_runtime_pair( + name = "py_runtime_pair", + py3_runtime = ":python37", +# py3_runtime = ":python38", +) + +toolchain( + name = "python_toolchain", + toolchain = ":py_runtime_pair", + toolchain_type = "@rules_python//python:toolchain_type", +) ) py_binary( diff --git a/WORKSPACE b/WORKSPACE index e1c0cc4..6971943 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -8,6 +8,8 @@ http_archive( load("@rules_python//python:pip.bzl", "pip_install") pip_install( - name = "my_deps", + name = "pip_requirements", requirements = "//:requirements.txt", ) + +register_toolchains("//:python_toolchain")