From 69f990673fb68a3d2afcd1e55460b962ae9c48cb Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Mon, 6 Jan 2020 15:57:36 -0800 Subject: [PATCH] Conform to protobuf's usage of six --- bazel/grpc_python_deps.bzl | 10 ++-------- examples/python/cancellation/BUILD.bazel | 2 +- src/python/grpcio/grpc/BUILD.bazel | 2 +- .../grpcio/grpc/framework/foundation/BUILD.bazel | 6 +++--- .../grpcio/grpc/framework/interfaces/base/BUILD.bazel | 2 +- .../grpcio/grpc/framework/interfaces/face/BUILD.bazel | 2 +- src/python/grpcio_tests/tests/unit/BUILD.bazel | 2 +- .../grpcio_tests/tests_aio/benchmark/BUILD.bazel | 2 +- src/python/grpcio_tests/tests_aio/unit/BUILD.bazel | 2 +- third_party/six.BUILD | 10 +++++++++- 10 files changed, 21 insertions(+), 19 deletions(-) diff --git a/bazel/grpc_python_deps.bzl b/bazel/grpc_python_deps.bzl index 8096121e877..b26c4fb0503 100644 --- a/bazel/grpc_python_deps.bzl +++ b/bazel/grpc_python_deps.bzl @@ -4,18 +4,12 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@com_github_grpc_grpc//third_party/py:python_configure.bzl", "python_configure") def grpc_python_deps(): - native.bind( - name = "six", - actual = "@six_archive//:six", - ) - # protobuf binds to the name "six", so we can't use it here. # See https://github.com/bazelbuild/bazel/issues/1952 for why bind is # horrible. - if "six_archive" not in native.existing_rules(): + if "six" not in native.existing_rules(): http_archive( - name = "six_archive", - strip_prefix = "six-1.12.0", + name = "six", build_file = "@com_github_grpc_grpc//third_party:six.BUILD", sha256 = "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73", urls = ["https://files.pythonhosted.org/packages/dd/bf/4138e7bfb757de47d1f4b6994648ec67a51efe58fa907c1e11e350cddfca/six-1.12.0.tar.gz"], diff --git a/examples/python/cancellation/BUILD.bazel b/examples/python/cancellation/BUILD.bazel index 56f5e8f0629..2c50f5b47cc 100644 --- a/examples/python/cancellation/BUILD.bazel +++ b/examples/python/cancellation/BUILD.bazel @@ -43,7 +43,7 @@ py_binary( deps = [ ":hash_name_py_pb2", ":hash_name_py_pb2_grpc", - "//external:six", + "@six//:six", "//src/python/grpcio/grpc:grpcio", ], ) diff --git a/src/python/grpcio/grpc/BUILD.bazel b/src/python/grpcio/grpc/BUILD.bazel index 786455ad3ec..dfcceb36571 100644 --- a/src/python/grpcio/grpc/BUILD.bazel +++ b/src/python/grpcio/grpc/BUILD.bazel @@ -18,7 +18,7 @@ py_library( "//src/python/grpcio/grpc/_cython:cygrpc", "//src/python/grpcio/grpc/experimental", "//src/python/grpcio/grpc/framework", - "@six_archive//:six", + "@six//:six", ] + select({ "//conditions:default": ["@enum34//:enum34"], "//:python3": [], diff --git a/src/python/grpcio/grpc/framework/foundation/BUILD.bazel b/src/python/grpcio/grpc/framework/foundation/BUILD.bazel index e5cf13ae4ce..6a353573a4a 100644 --- a/src/python/grpcio/grpc/framework/foundation/BUILD.bazel +++ b/src/python/grpcio/grpc/framework/foundation/BUILD.bazel @@ -22,7 +22,7 @@ py_library( name = "callable_util", srcs = ["callable_util.py"], deps = [ - "//external:six", + "@six//:six", ] + select({ "//conditions:default": ["@enum34//:enum34"], "//:python3": [], @@ -33,7 +33,7 @@ py_library( name = "future", srcs = ["future.py"], deps = [ - "//external:six", + "@six//:six", ], ) @@ -58,6 +58,6 @@ py_library( name = "stream", srcs = ["stream.py"], deps = [ - "//external:six", + "@six//:six", ], ) diff --git a/src/python/grpcio/grpc/framework/interfaces/base/BUILD.bazel b/src/python/grpcio/grpc/framework/interfaces/base/BUILD.bazel index b3b4e8dfdd2..fab7e1afd28 100644 --- a/src/python/grpcio/grpc/framework/interfaces/base/BUILD.bazel +++ b/src/python/grpcio/grpc/framework/interfaces/base/BUILD.bazel @@ -14,7 +14,7 @@ py_library( srcs = ["base.py"], deps = [ "//src/python/grpcio/grpc/framework/foundation:abandonment", - "//external:six", + "@six//:six", ] + select({ "//conditions:default": ["@enum34//:enum34"], "//:python3": [], diff --git a/src/python/grpcio/grpc/framework/interfaces/face/BUILD.bazel b/src/python/grpcio/grpc/framework/interfaces/face/BUILD.bazel index 0df15b02fcf..7255ca0041d 100644 --- a/src/python/grpcio/grpc/framework/interfaces/face/BUILD.bazel +++ b/src/python/grpcio/grpc/framework/interfaces/face/BUILD.bazel @@ -15,7 +15,7 @@ py_library( deps = [ "//src/python/grpcio/grpc/framework/foundation", "//src/python/grpcio/grpc/framework/common", - "//external:six", + "@six//:six", ] + select({ "//conditions:default": ["@enum34//:enum34"], "//:python3": [], diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel index fda39273586..8a42e5fc99a 100644 --- a/src/python/grpcio_tests/tests/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel @@ -102,7 +102,7 @@ py_library( ":resources", ":test_common", ":thread_pool", - "//external:six", + "@six//:six", "//src/python/grpcio/grpc:grpcio", "//src/python/grpcio_tests/tests/testing", "//src/python/grpcio_tests/tests/unit/framework/common", diff --git a/src/python/grpcio_tests/tests_aio/benchmark/BUILD.bazel b/src/python/grpcio_tests/tests_aio/benchmark/BUILD.bazel index c0947b9ee08..2957941b8c0 100644 --- a/src/python/grpcio_tests/tests_aio/benchmark/BUILD.bazel +++ b/src/python/grpcio_tests/tests_aio/benchmark/BUILD.bazel @@ -22,7 +22,7 @@ py_binary( srcs = ["server.py"], python_version = "PY3", deps = [ - "//external:six", + "@six//:six", "//src/proto/grpc/testing:benchmark_service_py_pb2", "//src/proto/grpc/testing:benchmark_service_py_pb2_grpc", "//src/proto/grpc/testing:py_messages_proto", diff --git a/src/python/grpcio_tests/tests_aio/unit/BUILD.bazel b/src/python/grpcio_tests/tests_aio/unit/BUILD.bazel index fd47d2c33d5..650132d1030 100644 --- a/src/python/grpcio_tests/tests_aio/unit/BUILD.bazel +++ b/src/python/grpcio_tests/tests_aio/unit/BUILD.bazel @@ -58,7 +58,7 @@ py_library( ":_constants", ":_test_base", ":_test_server", - "//external:six", + "@six//:six", "//src/proto/grpc/testing:benchmark_service_py_pb2", "//src/proto/grpc/testing:benchmark_service_py_pb2_grpc", "//src/proto/grpc/testing:py_messages_proto", diff --git a/third_party/six.BUILD b/third_party/six.BUILD index 60dc7811492..b048db024c5 100644 --- a/third_party/six.BUILD +++ b/third_party/six.BUILD @@ -1,6 +1,14 @@ +genrule( + name = "copy_six", + srcs = ["six-1.12.0/six.py"], + outs = ["__init__.py"], + cmd = "cp $< $(@)", +) + py_library( name = "six", - srcs = ["six.py"], + srcs = ["__init__.py"], srcs_version = "PY2AND3", visibility = ["//visibility:public"], ) +