Replace rules_pip with rules_python; use bazel built upstream grpc
instead of Python packages

As usual with Python sadness, the @pydeps wheels are built on the bazel
host, so stuffing them inside a container_image (or py_image) will cause
new and unexpected kinds of misery.

Change-Id: Id4e4d53741cf2da367f01aa15c21c133c5cf0dba
diff --git a/WORKSPACE b/WORKSPACE
index d3079bf..9474e10 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -5,6 +5,19 @@
 load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
 
+# Protobuf deps (shared between many rules).
+# Load this as early as possible, to avoid a different version being pulled in by deps of something else
+
+http_archive(
+    name = "com_google_protobuf",
+    sha256 = "bb8ce9ba11eb7bccf080599fe7cad9cc461751c8dd1ba61701c0070d58cde973",
+    strip_prefix = "protobuf-3.12.2",
+    urls = ["https://github.com/google/protobuf/archive/v3.12.2.tar.gz"],
+)
+
+load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
+protobuf_deps()
+
 # Go/Gazelle rules
 
 http_archive(
@@ -25,18 +38,43 @@
     ],
 )
 
-# Protobuf deps (shared between many rules).
+# Python rules
+
+# Important: rules_python must be loaded before protobuf (and grpc) because they load an older version otherwise
 
 http_archive(
-    name = "com_google_protobuf",
-    sha256 = "9748c0d90e54ea09e5e75fb7fac16edce15d2028d4356f32211cfa3c0e956564",
-    strip_prefix = "protobuf-3.11.4",
-    urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.11.4.zip"],
+    name = "rules_python",
+    url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.2/rules_python-0.0.2.tar.gz",
+    strip_prefix = "rules_python-0.0.2",
+    sha256 = "b5668cde8bb6e3515057ef465a35ad712214962f0b3a314e551204266c7be90c",
+)
+load("@rules_python//python:repositories.bzl", "py_repositories")
+py_repositories()
+
+load("@rules_python//python:pip.bzl", "pip_repositories")
+pip_repositories()
+
+load("@rules_python//python:pip.bzl", "pip3_import")
+pip3_import(
+   name = "pydeps",
+   requirements = "//third_party/py:requirements.txt",
 )
 
-load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
+load("@pydeps//:requirements.bzl", "pip_install")
+pip_install()
 
-protobuf_deps()
+# IMPORTANT: match protobuf version above with the one loaded by grpc
+http_archive(
+    name = "com_github_grpc_grpc",
+    sha256 = "419dba362eaf8f1d36849ceee17c3e2ff8ff12ac666b42d3ff02a164ebe090e9",
+    strip_prefix = "grpc-1.30.0",
+    urls = ["https://github.com/grpc/grpc/archive/v1.30.0.tar.gz"],
+)
+
+load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
+grpc_deps()
+load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
+grpc_extra_deps()
 
 # Go rules dependencies and our own dependencies.
 
@@ -74,28 +112,6 @@
 )
 container_repositories()
 
-# Python rules
-
-git_repository(
-    name = "com_apt_itude_rules_pip",
-    commit = "186bade4f054c0a9be7037585584c9c572cba483",
-    remote = "https://github.com/apt-itude/rules_pip.git",
-    shallow_since = "1564255337 -0400"
-)
-
-# Python dependencies
-load("@com_apt_itude_rules_pip//rules:dependencies.bzl", "pip_rules_dependencies")
-pip_rules_dependencies()
-
-load("@com_apt_itude_rules_pip//rules:repository.bzl", "pip_repository")
-pip_repository(
-    name = "pydeps",
-    requirements = "//third_party/py:requirements-lock.json",
-)
-
-load("@pydeps//:requirements.bzl", "pip_install")
-
-
 # Docker base images
 
 load("@io_bazel_rules_docker//container:container.bzl", "container_pull")