Add python bazel deps needed to run resolver component tests

This commit is contained in:
Alex Polcyn 2018-02-12 23:13:13 +00:00 коммит произвёл Alexander Polcyn
Родитель 86accb1768
Коммит aa56034b58
10 изменённых файлов: 150 добавлений и 10 удалений

Просмотреть файл

@ -1,4 +1,5 @@
workspace(name = "com_github_grpc_grpc")
load("//bazel:grpc_deps.bzl", "grpc_deps")
load("//bazel:grpc_deps.bzl", "grpc_deps", "grpc_test_only_deps")
grpc_deps()
grpc_test_only_deps()

Просмотреть файл

@ -165,8 +165,10 @@ def grpc_sh_binary(name, srcs, data = []):
def grpc_py_binary(name, srcs, data = [], deps = []):
if name == "test_dns_server":
# TODO: allow running test_dns_server in oss bazel test suite
deps = []
deps = _get_external_deps([
"twisted",
"yaml",
])
native.py_binary(
name = name,
srcs = srcs,

Просмотреть файл

@ -127,3 +127,57 @@ def grpc_deps():
],
sha256 = "ed829b5eea8af1f405f4cc3d6ecfc3b1365bb7843171036030a31b5127002311",
)
# TODO: move some dependencies from "grpc_deps" here?
def grpc_test_only_deps():
"""Internal, not intended for use by packages that are consuming grpc.
Loads dependencies that are only needed to run grpc library's tests."""
native.bind(
name = "twisted",
actual = "@com_github_twisted_twisted//:twisted",
)
native.bind(
name = "yaml",
actual = "@com_github_yaml_pyyaml//:yaml",
)
if "com_github_twisted_twisted" not in native.existing_rules():
native.new_http_archive(
name = "com_github_twisted_twisted",
strip_prefix = "twisted-twisted-17.5.0",
url = "https://github.com/twisted/twisted/archive/twisted-17.5.0.zip",
build_file = "@com_github_grpc_grpc//third_party:twisted.BUILD",
)
if "com_github_yaml_pyyaml" not in native.existing_rules():
native.new_http_archive(
name = "com_github_yaml_pyyaml",
strip_prefix = "pyyaml-3.12",
url = "https://github.com/yaml/pyyaml/archive/3.12.zip",
build_file = "@com_github_grpc_grpc//third_party:yaml.BUILD",
)
if "com_github_twisted_incremental" not in native.existing_rules():
native.new_http_archive(
name = "com_github_twisted_incremental",
strip_prefix = "incremental-incremental-17.5.0",
url = "https://github.com/twisted/incremental/archive/incremental-17.5.0.zip",
build_file = "@com_github_grpc_grpc//third_party:incremental.BUILD",
)
if "com_github_zopefoundation_zope_interface" not in native.existing_rules():
native.new_http_archive(
name = "com_github_zopefoundation_zope_interface",
strip_prefix = "zope.interface-4.4.3",
url = "https://github.com/zopefoundation/zope.interface/archive/4.4.3.zip",
build_file = "@com_github_grpc_grpc//third_party:zope_interface.BUILD",
)
if "com_github_twisted_constantly" not in native.existing_rules():
native.new_http_archive(
name = "com_github_twisted_constantly",
strip_prefix = "constantly-15.1.0",
url = "https://github.com/twisted/constantly/archive/15.1.0.zip",
build_file = "@com_github_grpc_grpc//third_party:constantly.BUILD",
)

5
third_party/BUILD поставляемый
Просмотреть файл

@ -3,4 +3,9 @@ exports_files([
"gtest.BUILD",
"objective_c/Cronet/bidirectional_stream_c.h",
"zlib.BUILD",
"twisted.BUILD",
"yaml.BUILD",
"incremental.BUILD",
"zope_interface.BUILD",
"constantly.BUILD",
])

7
third_party/constantly.BUILD поставляемый Normal file
Просмотреть файл

@ -0,0 +1,7 @@
py_library(
name = "constantly",
srcs = glob(["constantly/*.py"]),
visibility = [
"//visibility:public",
],
)

10
third_party/incremental.BUILD поставляемый Normal file
Просмотреть файл

@ -0,0 +1,10 @@
py_library(
name = "incremental",
srcs = glob(["src/incremental/*.py"]),
imports = [
"src",
],
visibility = [
"//visibility:public",
],
)

15
third_party/twisted.BUILD поставляемый Normal file
Просмотреть файл

@ -0,0 +1,15 @@
py_library(
name = "twisted",
srcs = glob(["src/twisted/**/*.py"]),
imports = [
"src",
],
visibility = [
"//visibility:public",
],
deps = [
"@com_github_twisted_incremental//:incremental",
"@com_github_twisted_constantly//:constantly",
"@com_github_zopefoundation_zope_interface//:zope_interface",
],
)

10
third_party/yaml.BUILD поставляемый Normal file
Просмотреть файл

@ -0,0 +1,10 @@
py_library(
name = "yaml",
srcs = glob(["lib/yaml/*.py"]),
imports = [
"lib",
],
visibility = [
"//visibility:public",
],
)

13
third_party/zope_interface.BUILD поставляемый Normal file
Просмотреть файл

@ -0,0 +1,13 @@
py_library(
name = "zope_interface",
srcs = glob([
"src/zope/interface/*.py",
"src/zope/interface/common/*.py",
]),
imports = [
"src",
],
visibility = [
"//visibility:public",
],
)

Просмотреть файл

@ -35,6 +35,11 @@ git_submodule_hashes = {
}
_BAZEL_TOOLCHAINS_DEP_NAME = 'com_github_bazelbuild_bazeltoolchains'
_TWISTED_TWISTED_DEP_NAME = 'com_github_twisted_twisted'
_YAML_PYYAML_DEP_NAME = 'com_github_yaml_pyyaml'
_TWISTED_INCREMENTAL_DEP_NAME = 'com_github_twisted_incremental'
_ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME = 'com_github_zopefoundation_zope_interface'
_TWISTED_CONSTANTLY_DEP_NAME = 'com_github_twisted_constantly'
_GRPC_DEP_NAMES = [
'boringssl',
@ -46,6 +51,20 @@ _GRPC_DEP_NAMES = [
'com_github_cares_cares',
'com_google_absl',
_BAZEL_TOOLCHAINS_DEP_NAME,
_TWISTED_TWISTED_DEP_NAME,
_YAML_PYYAML_DEP_NAME,
_TWISTED_INCREMENTAL_DEP_NAME,
_ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME,
_TWISTED_CONSTANTLY_DEP_NAME,
]
_GRPC_BAZEL_ONLY_DEPS = [
_BAZEL_TOOLCHAINS_DEP_NAME,
_TWISTED_TWISTED_DEP_NAME,
_YAML_PYYAML_DEP_NAME,
_TWISTED_INCREMENTAL_DEP_NAME,
_ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME,
_TWISTED_CONSTANTLY_DEP_NAME,
]
@ -70,7 +89,8 @@ class BazelEvalState(object):
return []
def archive(self, **args):
if args['name'] == _BAZEL_TOOLCHAINS_DEP_NAME:
assert self.names_and_urls.get(args['name']) is None
if args['name'] in _GRPC_BAZEL_ONLY_DEPS:
self.names_and_urls[args['name']] = 'dont care'
return
self.names_and_urls[args['name']] = args['url']
@ -82,8 +102,10 @@ with open(os.path.join('bazel', 'grpc_deps.bzl'), 'r') as f:
eval_state = BazelEvalState(names_and_urls)
bazel_file = f.read()
# grpc_deps.bzl only defines 'grpc_deps', add this to call it
# grpc_deps.bzl only defines 'grpc_deps' and 'grpc_test_only_deps', add these
# lines to call them.
bazel_file += '\ngrpc_deps()\n'
bazel_file += '\ngrpc_test_only_deps()\n'
build_rules = {
'native': eval_state,
}
@ -92,11 +114,12 @@ for name in _GRPC_DEP_NAMES:
assert name in names_and_urls.keys()
assert len(_GRPC_DEP_NAMES) == len(names_and_urls.keys())
# bazeltoolschains is an exception to this sanity check,
# we don't require that there is a corresponding git module.
names_without_bazeltoolchains = names_and_urls.keys()
names_without_bazeltoolchains.remove(_BAZEL_TOOLCHAINS_DEP_NAME)
archive_urls = [names_and_urls[name] for name in names_without_bazeltoolchains]
# There are some "bazel-only" deps that are exceptions to this sanity check,
# we don't require that there is a corresponding git module for these.
names_without_bazel_only_deps = names_and_urls.keys()
for dep_name in _GRPC_BAZEL_ONLY_DEPS:
names_without_bazel_only_deps.remove(dep_name)
archive_urls = [names_and_urls[name] for name in names_without_bazel_only_deps]
workspace_git_hashes = {
re.search(git_hash_pattern, url).group()
for url in archive_urls