Skip to content

Commit 7da0aac

Browse files
committed
Revert "Merge pull request grpc#17644 from lidizheng/bzl-py3"
This reverts commit a25828a, reversing changes made to 5176fd8.
1 parent 6d35804 commit 7da0aac

File tree

17 files changed

+36
-117
lines changed

17 files changed

+36
-117
lines changed

BUILD

-5
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ config_setting(
6363
values = {"cpu": "x64_windows_msvc"},
6464
)
6565

66-
config_setting(
67-
name = "python3",
68-
values = {"python_path": "python3"},
69-
)
70-
7166
# This should be updated along with build.yaml
7267
g_stands_for = "gold"
7368

src/python/grpcio/grpc/BUILD.bazel

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ py_library(
1515
"//src/python/grpcio/grpc/_cython:cygrpc",
1616
"//src/python/grpcio/grpc/experimental",
1717
"//src/python/grpcio/grpc/framework",
18+
requirement('enum34'),
1819
requirement('six'),
19-
] + select({
20-
"//conditions:default": [requirement('enum34'),],
21-
"//:python3": [],
22-
}),
20+
],
2321
data = [
2422
"//:grpc",
2523
],

src/python/grpcio/grpc/framework/common/BUILD.bazel

+6-8
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ py_library(
1313
py_library(
1414
name = "cardinality",
1515
srcs = ["cardinality.py"],
16-
deps = select({
17-
"//conditions:default": [requirement('enum34'),],
18-
"//:python3": [],
19-
}),
16+
deps = [
17+
requirement("enum34"),
18+
],
2019
)
2120

2221
py_library(
2322
name = "style",
2423
srcs = ["style.py"],
25-
deps = select({
26-
"//conditions:default": [requirement('enum34'),],
27-
"//:python3": [],
28-
}),
24+
deps = [
25+
requirement("enum34"),
26+
],
2927
)

src/python/grpcio/grpc/framework/foundation/BUILD.bazel

+5-8
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ py_library(
2323
name = "callable_util",
2424
srcs = ["callable_util.py"],
2525
deps = [
26+
requirement("enum34"),
2627
requirement("six"),
27-
] + select({
28-
"//conditions:default": [requirement('enum34'),],
29-
"//:python3": [],
30-
}),
28+
],
3129
)
3230

3331
py_library(
@@ -41,10 +39,9 @@ py_library(
4139
py_library(
4240
name = "logging_pool",
4341
srcs = ["logging_pool.py"],
44-
deps = select({
45-
"//conditions:default": [requirement('futures'),],
46-
"//:python3": [],
47-
}),
42+
deps = [
43+
requirement("futures"),
44+
],
4845
)
4946

5047
py_library(

src/python/grpcio/grpc/framework/interfaces/base/BUILD.bazel

+5-8
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,15 @@ py_library(
1515
srcs = ["base.py"],
1616
deps = [
1717
"//src/python/grpcio/grpc/framework/foundation:abandonment",
18+
requirement("enum34"),
1819
requirement("six"),
19-
] + select({
20-
"//conditions:default": [requirement('enum34'),],
21-
"//:python3": [],
22-
}),
20+
],
2321
)
2422

2523
py_library(
2624
name = "utilities",
2725
srcs = ["utilities.py"],
28-
deps = select({
29-
"//conditions:default": [requirement('enum34'),],
30-
"//:python3": [],
31-
}),
26+
deps = [
27+
requirement("enum34"),
28+
],
3229
)

src/python/grpcio/grpc/framework/interfaces/face/BUILD.bazel

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ py_library(
1616
deps = [
1717
"//src/python/grpcio/grpc/framework/foundation",
1818
"//src/python/grpcio/grpc/framework/common",
19+
requirement("enum34"),
1920
requirement("six"),
20-
] + select({
21-
"//conditions:default": [requirement('enum34'),],
22-
"//:python3": [],
23-
}),
21+
],
2422
)
2523

2624
py_library(

src/python/grpcio_status/grpc_status/rpc_status.py

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717

1818
import grpc
1919

20+
# TODO(https://github.com/bazelbuild/bazel/issues/6844)
21+
# Due to Bazel issue, the namespace packages won't resolve correctly.
22+
# Adding this unused-import as a workaround to avoid module-not-found error
23+
# under Bazel builds.
24+
import google.protobuf # pylint: disable=unused-import
2025
from google.rpc import status_pb2
2126

2227
_CODE_TO_GRPC_CODE_MAPPING = {x.value[0]: x for x in grpc.StatusCode}

src/python/grpcio_tests/tests/BUILD.bazel

-8
This file was deleted.

src/python/grpcio_tests/tests/bazel_namespace_package_hack.py

-32
This file was deleted.

src/python/grpcio_tests/tests/interop/BUILD.bazel

+2-5
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,17 @@ py_library(
2929
srcs = ["methods.py"],
3030
deps = [
3131
"//src/python/grpcio/grpc:grpcio",
32-
"//src/python/grpcio_tests/tests:bazel_namespace_package_hack",
3332
"//src/proto/grpc/testing:py_empty_proto",
3433
"//src/proto/grpc/testing:py_messages_proto",
3534
"//src/proto/grpc/testing:py_test_proto",
3635
requirement('google-auth'),
3736
requirement('requests'),
37+
requirement('enum34'),
3838
requirement('urllib3'),
3939
requirement('chardet'),
4040
requirement('certifi'),
4141
requirement('idna'),
42-
] + select({
43-
"//conditions:default": [requirement('enum34'),],
44-
"//:python3": [],
45-
}),
42+
],
4643
imports=["../../",],
4744
)
4845

src/python/grpcio_tests/tests/interop/methods.py

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
# limitations under the License.
1414
"""Implementations of interoperability test methods."""
1515

16-
from tests import bazel_namespace_package_hack
17-
bazel_namespace_package_hack.sys_path_to_site_dir_hack()
18-
1916
import enum
2017
import json
2118
import os

src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py

+5-15
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,6 @@ def _file_descriptor_to_proto(descriptor):
5050

5151
class ReflectionServicerTest(unittest.TestCase):
5252

53-
# TODO(https://github.com/grpc/grpc/issues/17844)
54-
# Bazel + Python 3 will result in creating two different instance of
55-
# DESCRIPTOR for each message. So, the equal comparison between protobuf
56-
# returned by stub and manually crafted protobuf will always fail.
57-
def _assert_sequence_of_proto_equal(self, x, y):
58-
self.assertSequenceEqual(
59-
list(map(lambda x: x.SerializeToString(), x)),
60-
list(map(lambda x: x.SerializeToString(), y)),
61-
)
62-
6353
def setUp(self):
6454
self._server = test_common.test_server()
6555
reflection.enable_server_reflection(_SERVICE_NAMES, self._server)
@@ -94,7 +84,7 @@ def testFileByName(self):
9484
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
9585
)),
9686
)
97-
self._assert_sequence_of_proto_equal(expected_responses, responses)
87+
self.assertSequenceEqual(expected_responses, responses)
9888

9989
def testFileBySymbol(self):
10090
requests = (
@@ -118,7 +108,7 @@ def testFileBySymbol(self):
118108
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
119109
)),
120110
)
121-
self._assert_sequence_of_proto_equal(expected_responses, responses)
111+
self.assertSequenceEqual(expected_responses, responses)
122112

123113
def testFileContainingExtension(self):
124114
requests = (
@@ -147,7 +137,7 @@ def testFileContainingExtension(self):
147137
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
148138
)),
149139
)
150-
self._assert_sequence_of_proto_equal(expected_responses, responses)
140+
self.assertSequenceEqual(expected_responses, responses)
151141

152142
def testExtensionNumbersOfType(self):
153143
requests = (
@@ -172,7 +162,7 @@ def testExtensionNumbersOfType(self):
172162
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
173163
)),
174164
)
175-
self._assert_sequence_of_proto_equal(expected_responses, responses)
165+
self.assertSequenceEqual(expected_responses, responses)
176166

177167
def testListServices(self):
178168
requests = (reflection_pb2.ServerReflectionRequest(list_services='',),)
@@ -183,7 +173,7 @@ def testListServices(self):
183173
service=tuple(
184174
reflection_pb2.ServiceResponse(name=name)
185175
for name in _SERVICE_NAMES))),)
186-
self._assert_sequence_of_proto_equal(expected_responses, responses)
176+
self.assertSequenceEqual(expected_responses, responses)
187177

188178
def testReflectionServiceName(self):
189179
self.assertEqual(reflection.SERVICE_NAME,

src/python/grpcio_tests/tests/status/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ py_test(
1010
deps = [
1111
"//src/python/grpcio/grpc:grpcio",
1212
"//src/python/grpcio_status/grpc_status:grpc_status",
13-
"//src/python/grpcio_tests/tests:bazel_namespace_package_hack",
1413
"//src/python/grpcio_tests/tests/unit:test_common",
1514
"//src/python/grpcio_tests/tests/unit/framework/common:common",
1615
requirement('protobuf'),

src/python/grpcio_tests/tests/status/_grpc_status_test.py

-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
# limitations under the License.
1414
"""Tests of grpc_status."""
1515

16-
from tests import bazel_namespace_package_hack
17-
bazel_namespace_package_hack.sys_path_to_site_dir_hack()
18-
1916
import unittest
2017

2118
import logging

third_party/py/python_configure.bzl

+4-7
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,10 @@ def _symlink_genrule_for_dir(repository_ctx,
138138

139139
def _get_python_bin(repository_ctx):
140140
"""Gets the python bin path."""
141-
python_bin = repository_ctx.os.environ.get(_PYTHON_BIN_PATH, 'python')
142-
if not '/' in python_bin and not '\\' in python_bin:
143-
# It's a command, use 'which' to find its path.
144-
python_bin_path = repository_ctx.which(python_bin)
145-
else:
146-
# It's a path, use it as it is.
147-
python_bin_path = python_bin
141+
python_bin = repository_ctx.os.environ.get(_PYTHON_BIN_PATH)
142+
if python_bin != None:
143+
return python_bin
144+
python_bin_path = repository_ctx.which("python")
148145
if python_bin_path != None:
149146
return str(python_bin_path)
150147
_fail("Cannot find python in PATH, please make sure " +

tools/bazel.rc

-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,3 @@ build:basicprof --copt=-DNDEBUG
5757
build:basicprof --copt=-O2
5858
build:basicprof --copt=-DGRPC_BASIC_PROFILER
5959
build:basicprof --copt=-DGRPC_TIMERS_RDTSC
60-
61-
build:python3 --python_path=python3
62-
build:python3 --force_python=PY3
63-
build:python3 --action_env=PYTHON_BIN_PATH=python3

tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh

-2
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@ git clone /var/local/jenkins/grpc /var/local/git/grpc
2525
${name}')
2626
cd /var/local/git/grpc/test
2727
bazel test --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/...
28-
bazel clean --expunge
29-
bazel test --config=python3 --spawn_strategy=standalone --genrule_strategy=standalone --test_output=errors //src/python/...

0 commit comments

Comments
 (0)