From 68e13f40f4d41d1d3cf8ec6382ac9e7ad132daf9 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Thu, 22 Oct 2015 11:13:14 -0700 Subject: [PATCH 1/4] Enable python tests with testdata. --- BUILD | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/BUILD b/BUILD index a0f291f7be..c08824d84e 100644 --- a/BUILD +++ b/BUILD @@ -534,7 +534,10 @@ py_proto_library( py_proto_library( name = "python_specific_test_protos", - srcs = glob(["python/google/protobuf/internal/*.proto"]), + srcs = glob([ + "python/google/protobuf/internal/*.proto", + "python/google/protobuf/internal/import_test_package/*.proto", + ]), include = "python", protoc = ":protoc", deps = [":python_common_test_protos"], @@ -552,6 +555,9 @@ py_library( internal_protobuf_py_tests( name = "python_tests_batch", + data = glob([ + "src/google/protobuf/**/*", + ]), modules = [ "descriptor_database_test", "descriptor_pool_test", @@ -559,13 +565,13 @@ internal_protobuf_py_tests( "generator_test", "json_format_test", "message_factory_test", - # "message_test", # failed due to testdata path + "message_test", "proto_builder_test", - # "reflection_test", # failed due to testdata path + "reflection_test", "service_reflection_test", "symbol_database_test", "text_encoding_test", - # "text_format_test", # failed due to testdata path + "text_format_test", "unknown_fields_test", "wire_format_test", ], From fbc51b70181d80bc1dc45230495ca896d54f5193 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Thu, 22 Oct 2015 13:38:17 -0700 Subject: [PATCH 2/4] Add six as an external dep. --- BUILD | 1 + WORKSPACE | 13 +++++++++++++ six.BUILD | 5 +++++ 3 files changed, 19 insertions(+) create mode 100644 six.BUILD diff --git a/BUILD b/BUILD index c08824d84e..0401e2c48d 100644 --- a/BUILD +++ b/BUILD @@ -510,6 +510,7 @@ py_proto_library( include = "src", protoc = ":protoc", py_extra_srcs = [":python_srcs"], + py_libs = ["//external:six"], visibility = ["//visibility:public"], ) diff --git a/WORKSPACE b/WORKSPACE index f72f239a06..42d9328a94 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -5,6 +5,14 @@ new_http_archive( build_file = "gmock.BUILD", ) +new_http_archive( + name = "six_archive", + url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55", + sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", + build_file = "six.BUILD", + strip_prefix = "six-1.10.0", +) + bind( name = "gtest", actual = "@gmock_archive//:gtest", @@ -14,3 +22,8 @@ bind( name = "gtest_main", actual = "@gmock_archive//:gtest_main", ) + +bind( + name = "six", + actual = "@six_archive//:six", +) diff --git a/six.BUILD b/six.BUILD new file mode 100644 index 0000000000..a259232db7 --- /dev/null +++ b/six.BUILD @@ -0,0 +1,5 @@ +py_library( + name = "six", + srcs = ["six-1.10.0/six.py"], + visibility = ["//visibility:public"], +) From b657cb4b918306a7a1492f3764b63a4aaea4162a Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Thu, 22 Oct 2015 13:44:15 -0700 Subject: [PATCH 3/4] fix six package path. --strip_prefix doesn't seem to work. --- WORKSPACE | 1 - six.BUILD | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 42d9328a94..c3f18cc7b7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -10,7 +10,6 @@ new_http_archive( url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55", sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", build_file = "six.BUILD", - strip_prefix = "six-1.10.0", ) bind( diff --git a/six.BUILD b/six.BUILD index a259232db7..55c53a4231 100644 --- a/six.BUILD +++ b/six.BUILD @@ -1,5 +1,12 @@ +genrule( + name = "copy_six", + srcs = ["six-1.10.0/six.py"], + outs = ["six.py"], + cmd = "cp $< $(@)", +) + py_library( name = "six", - srcs = ["six-1.10.0/six.py"], + srcs = ["six.py"], visibility = ["//visibility:public"], ) From e1f60f50430466003ede6cbd27ea133422958b8f Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Thu, 22 Oct 2015 13:55:37 -0700 Subject: [PATCH 4/4] Update comments. --- BUILD | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BUILD b/BUILD index 0401e2c48d..4f2bc28722 100644 --- a/BUILD +++ b/BUILD @@ -472,8 +472,6 @@ java_library( # Python support ################################################################################ -# Requires: six for python 2/3 compatibility. `pip install six` - # Hack: # protoc generated files contain imports like: # "from google.protobuf.xxx import yyy" @@ -485,10 +483,13 @@ java_library( # that depend on the target. # # If you use python protobuf as a third_party library in your bazel managed -# project, please import the whole package to //google/protobuf in your +# project: +# 1) Please import the whole package to //google/protobuf in your # project. Otherwise, bazel disallows generated files out of the current # package, thus we won't be able to copy protobuf runtime files into # //google/protobuf/. +# 2) The runtime also requires "six" for Python2/3 compatibility, please see the +# WORKSPACE file and bind "six" to your workspace as well. internal_copied_filegroup( name = "python_srcs", srcs = glob(