Skip to content

Commit

Permalink
List validator.py as a dependency for py harness (#434)
Browse files Browse the repository at this point in the history
Instead of hackily adjusting the Python path during execution, create a
py_library rule for validator.py and list it as a dependency of the
python harness binary.

Signed-off-by: Alex Konradi <akonradi@google.com>
  • Loading branch information
akonradi authored Mar 5, 2021
1 parent 2ad6ea2 commit b79666f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions tests/harness/python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ py_binary(
name = "python-harness",
srcs = ["harness.py"],
main = "harness.py",
srcs_version = "PY3",
visibility = ["//tests/harness:__subpackages__"],
deps = [
"//tests/harness:python-harness-proto",
"//tests/harness/cases:python",
"//validate:validator_py",
requirement("validate-email"),
requirement("ipaddress"),
requirement("Jinja2"),
Expand Down
3 changes: 1 addition & 2 deletions tests/harness/python/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
from tests.harness.cases.wkt_timestamp_pb2 import *
from tests.harness.cases.kitchen_sink_pb2 import *

sys.path.append(os.environ['GOPATH']+'/src/github.com/envoyproxy/protoc-gen-validate/validate')
from validator import validate, ValidationFailed, UnimplementedException, print_validate
from validate.validator import validate, ValidationFailed, UnimplementedException, print_validate

class_list = []
for k, v in inspect.getmembers(sys.modules[__name__], inspect.isclass):
Expand Down
17 changes: 11 additions & 6 deletions validate/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

package(
default_visibility =
["//visibility:public"],
)

proto_library(
name = "validate_proto",
srcs = ["validate.proto"],
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
Expand All @@ -17,7 +21,6 @@ proto_library(

cc_proto_library(
name = "validate_cc",
visibility = ["//visibility:public"],
deps = [":validate_proto"],
)

Expand All @@ -26,25 +29,27 @@ py_proto_library(
srcs = ["validate.proto"],
default_runtime = "@com_google_protobuf//:protobuf_python",
protoc = "@com_google_protobuf//:protoc",
visibility = ["//visibility:public"],
deps = ["@com_google_protobuf//:protobuf_python"],
)

go_proto_library(
name = "go_default_library",
importpath = "github.com/envoyproxy/protoc-gen-validate/validate",
proto = ":validate_proto",
visibility = ["//visibility:public"],
)

cc_library(
name = "cc_validate",
hdrs = ["validate.h"],
visibility = ["//visibility:public"],
)

java_proto_library(
name = "validate_java",
visibility = ["//visibility:public"],
deps = [":validate_proto"],
)

py_library(
name = "validator_py",
srcs = ["validator.py"],
srcs_version = "PY3",
)

0 comments on commit b79666f

Please sign in to comment.