From 341c65bbbf8c45e3df79245c3d4dc206cf04acc9 Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Thu, 24 Oct 2019 20:02:07 +0200 Subject: [PATCH 1/4] [bazel] Add `strip_prefix` to download of @six This way, we can avoid an unnecessary copy. --- protobuf_deps.bzl | 1 + third_party/six.BUILD | 15 +++++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index 9209b1c5a3ca..b5971a5a374f 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -27,6 +27,7 @@ def protobuf_deps(): name = "six", build_file = "@com_google_protobuf//:third_party/six.BUILD", sha256 = "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73", + strip_prefix = "six-1.12.0", urls = ["https://pypi.python.org/packages/source/s/six/six-1.12.0.tar.gz"], ) diff --git a/third_party/six.BUILD b/third_party/six.BUILD index 88c75520defb..327049cd1483 100644 --- a/third_party/six.BUILD +++ b/third_party/six.BUILD @@ -1,13 +1,8 @@ -genrule( - name = "copy_six", - srcs = ["six-1.12.0/six.py"], - outs = ["__init__.py"], - cmd = "cp $< $(@)", -) +load("@rules_python//python:defs.bzl", "py_library") py_library( - name = "six", - srcs = ["__init__.py"], - srcs_version = "PY2AND3", - visibility = ["//visibility:public"], + name = "six", + srcs = ["six.py"], + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], ) From 719fbe14852ec7bbeba2c8bbc7a0666bf34803a4 Mon Sep 17 00:00:00 2001 From: Yannic Date: Fri, 25 Oct 2019 14:12:16 +0200 Subject: [PATCH 2/4] Update protobuf_deps.bzl --- protobuf_deps.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index b5971a5a374f..9209b1c5a3ca 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -27,7 +27,6 @@ def protobuf_deps(): name = "six", build_file = "@com_google_protobuf//:third_party/six.BUILD", sha256 = "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73", - strip_prefix = "six-1.12.0", urls = ["https://pypi.python.org/packages/source/s/six/six-1.12.0.tar.gz"], ) From db0116d3eabdb8dd622770550348d21373e2fa3c Mon Sep 17 00:00:00 2001 From: Yannic Date: Fri, 25 Oct 2019 14:12:36 +0200 Subject: [PATCH 3/4] Update six.BUILD --- third_party/six.BUILD | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/third_party/six.BUILD b/third_party/six.BUILD index 327049cd1483..5d66ba7d6148 100644 --- a/third_party/six.BUILD +++ b/third_party/six.BUILD @@ -1,8 +1,19 @@ load("@rules_python//python:defs.bzl", "py_library") +# Consume `six.py` as `__init__.py` for compatibility +# with `--incompatible_default_to_explicit_init_py`. +# https://github.com/protocolbuffers/protobuf/pull/6795#issuecomment-546060749 +# https://github.com/bazelbuild/bazel/issues/10076 +genrule( + name = "copy_six", + srcs = ["six-1.12.0/six.py"], + outs = ["__init__.py"], + cmd = "cp $< $(@)", +) + py_library( - name = "six", - srcs = ["six.py"], - srcs_version = "PY2AND3", - visibility = ["//visibility:public"], + name = "six", + srcs = ["__init__.py"], + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], ) From 95b30973298578d47100ba22fbcfdd3c519acca8 Mon Sep 17 00:00:00 2001 From: Yannic Date: Fri, 25 Oct 2019 14:13:41 +0200 Subject: [PATCH 4/4] Update six.BUILD --- third_party/six.BUILD | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/third_party/six.BUILD b/third_party/six.BUILD index 5d66ba7d6148..041c72c66ed2 100644 --- a/third_party/six.BUILD +++ b/third_party/six.BUILD @@ -5,15 +5,15 @@ load("@rules_python//python:defs.bzl", "py_library") # https://github.com/protocolbuffers/protobuf/pull/6795#issuecomment-546060749 # https://github.com/bazelbuild/bazel/issues/10076 genrule( - name = "copy_six", - srcs = ["six-1.12.0/six.py"], - outs = ["__init__.py"], - cmd = "cp $< $(@)", + name = "copy_six", + srcs = ["six-1.12.0/six.py"], + outs = ["__init__.py"], + cmd = "cp $< $(@)", ) py_library( - name = "six", - srcs = ["__init__.py"], - srcs_version = "PY2AND3", - visibility = ["//visibility:public"], + name = "six", + srcs = ["__init__.py"], + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], )