Skip to content
Snippets Groups Projects
Commit fb261bf7 authored by Masood Malekghassemi's avatar Masood Malekghassemi
Browse files

Un-namespace Python packages

Setuptools was updated and our hacky namespace-package-chickens came
back to roost. This removes the unsupported namespace package hacks.
parent 4603a1c7
No related branches found
No related tags found
No related merge requests found
Showing
with 19 additions and 111 deletions
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
"""Generates protocol messages and gRPC stubs.""" """Generates protocol messages and gRPC stubs."""
from grpc.tools import protoc from grpc_tools import protoc
protoc.main( protoc.main(
( (
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
"""Runs protoc with the gRPC plugin to generate messages and gRPC stubs.""" """Runs protoc with the gRPC plugin to generate messages and gRPC stubs."""
from grpc.tools import protoc from grpc_tools import protoc
protoc.main( protoc.main(
( (
......
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
__import__('pkg_resources').declare_namespace(__name__)
...@@ -33,7 +33,7 @@ import threading ...@@ -33,7 +33,7 @@ import threading
import grpc import grpc
from grpc.health.v1 import health_pb2 from grpc_health.v1 import health_pb2
class HealthServicer(health_pb2.HealthServicer): class HealthServicer(health_pb2.HealthServicer):
......
...@@ -54,7 +54,7 @@ class CopyProtoModules(setuptools.Command): ...@@ -54,7 +54,7 @@ class CopyProtoModules(setuptools.Command):
if os.path.isfile(HEALTH_PROTO): if os.path.isfile(HEALTH_PROTO):
shutil.copyfile( shutil.copyfile(
HEALTH_PROTO, HEALTH_PROTO,
os.path.join(ROOT_DIR, 'grpc/health/v1/health.proto')) os.path.join(ROOT_DIR, 'grpc_health/v1/health.proto'))
class BuildPackageProtos(setuptools.Command): class BuildPackageProtos(setuptools.Command):
...@@ -74,5 +74,5 @@ class BuildPackageProtos(setuptools.Command): ...@@ -74,5 +74,5 @@ class BuildPackageProtos(setuptools.Command):
# directory is provided as an 'include' directory. We assume it's the '' key # directory is provided as an 'include' directory. We assume it's the '' key
# to `self.distribution.package_dir` (and get a key error if it's not # to `self.distribution.package_dir` (and get a key error if it's not
# there). # there).
from grpc.tools import command from grpc_tools import command
command.build_package_protos(self.distribution.package_dir['']) command.build_package_protos(self.distribution.package_dir[''])
...@@ -66,7 +66,6 @@ setuptools.setup( ...@@ -66,7 +66,6 @@ setuptools.setup(
license='3-clause BSD', license='3-clause BSD',
package_dir=PACKAGE_DIRECTORIES, package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages('.'), packages=setuptools.find_packages('.'),
namespace_packages=['grpc'],
install_requires=INSTALL_REQUIRES, install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES, setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS cmdclass=COMMAND_CLASS
......
# Copyright 2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
__import__('pkg_resources').declare_namespace(__name__)
...@@ -35,7 +35,7 @@ import grpc ...@@ -35,7 +35,7 @@ import grpc
from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool from google.protobuf import descriptor_pool
from grpc.reflection.v1alpha import reflection_pb2 from grpc_reflection.v1alpha import reflection_pb2
_POOL = descriptor_pool.Default() _POOL = descriptor_pool.Default()
......
...@@ -54,7 +54,7 @@ class CopyProtoModules(setuptools.Command): ...@@ -54,7 +54,7 @@ class CopyProtoModules(setuptools.Command):
if os.path.isfile(HEALTH_PROTO): if os.path.isfile(HEALTH_PROTO):
shutil.copyfile( shutil.copyfile(
HEALTH_PROTO, HEALTH_PROTO,
os.path.join(ROOT_DIR, 'grpc/reflection/v1alpha/reflection.proto')) os.path.join(ROOT_DIR, 'grpc_reflection/v1alpha/reflection.proto'))
class BuildPackageProtos(setuptools.Command): class BuildPackageProtos(setuptools.Command):
...@@ -74,5 +74,5 @@ class BuildPackageProtos(setuptools.Command): ...@@ -74,5 +74,5 @@ class BuildPackageProtos(setuptools.Command):
# directory is provided as an 'include' directory. We assume it's the '' key # directory is provided as an 'include' directory. We assume it's the '' key
# to `self.distribution.package_dir` (and get a key error if it's not # to `self.distribution.package_dir` (and get a key error if it's not
# there). # there).
from grpc.tools import command from grpc_tools import command
command.build_package_protos(self.distribution.package_dir['']) command.build_package_protos(self.distribution.package_dir[''])
...@@ -66,7 +66,6 @@ setuptools.setup( ...@@ -66,7 +66,6 @@ setuptools.setup(
license='3-clause BSD', license='3-clause BSD',
package_dir=PACKAGE_DIRECTORIES, package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages('.'), packages=setuptools.find_packages('.'),
namespace_packages=['grpc'],
install_requires=INSTALL_REQUIRES, install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES, setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS cmdclass=COMMAND_CLASS
......
...@@ -100,7 +100,7 @@ class BuildProtoModules(setuptools.Command): ...@@ -100,7 +100,7 @@ class BuildProtoModules(setuptools.Command):
pass pass
def run(self): def run(self):
import grpc.tools.protoc as protoc import grpc_tools.protoc as protoc
include_regex = re.compile(self.include) include_regex = re.compile(self.include)
exclude_regex = re.compile(self.exclude) if self.exclude else None exclude_regex = re.compile(self.exclude) if self.exclude else None
...@@ -116,7 +116,7 @@ class BuildProtoModules(setuptools.Command): ...@@ -116,7 +116,7 @@ class BuildProtoModules(setuptools.Command):
# but we currently have name conflicts in src/proto # but we currently have name conflicts in src/proto
for path in paths: for path in paths:
command = [ command = [
'grpc.tools.protoc', 'grpc_tools.protoc',
'-I {}'.format(PROTO_STEM), '-I {}'.format(PROTO_STEM),
'--python_out={}'.format(PROTO_STEM), '--python_out={}'.format(PROTO_STEM),
'--grpc_python_out={}'.format(PROTO_STEM), '--grpc_python_out={}'.format(PROTO_STEM),
......
...@@ -35,7 +35,7 @@ import sys ...@@ -35,7 +35,7 @@ import sys
import setuptools import setuptools
import grpc.tools.command import grpc_tools.command
PY3 = sys.version_info.major == 3 PY3 = sys.version_info.major == 3
...@@ -68,7 +68,7 @@ COMMAND_CLASS = { ...@@ -68,7 +68,7 @@ COMMAND_CLASS = {
# Run `preprocess` *before* doing any packaging! # Run `preprocess` *before* doing any packaging!
'preprocess': commands.GatherProto, 'preprocess': commands.GatherProto,
'build_package_protos': grpc.tools.command.BuildPackageProtos, 'build_package_protos': grpc_tools.command.BuildPackageProtos,
'build_py': commands.BuildPy, 'build_py': commands.BuildPy,
'run_interop': commands.RunInterop, 'run_interop': commands.RunInterop,
'test_lite': commands.TestLite 'test_lite': commands.TestLite
......
...@@ -27,14 +27,14 @@ ...@@ -27,14 +27,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Tests of grpc.health.v1.health.""" """Tests of grpc_health.v1.health."""
import unittest import unittest
import grpc import grpc
from grpc.framework.foundation import logging_pool from grpc.framework.foundation import logging_pool
from grpc.health.v1 import health from grpc_health.v1 import health
from grpc.health.v1 import health_pb2 from grpc_health.v1 import health_pb2
from tests.unit.framework.common import test_constants from tests.unit.framework.common import test_constants
......
...@@ -44,7 +44,7 @@ import threading ...@@ -44,7 +44,7 @@ import threading
import unittest import unittest
import grpc import grpc
from grpc.tools import protoc from grpc_tools import protoc
from tests.unit.framework.common import test_constants from tests.unit.framework.common import test_constants
_MESSAGES_IMPORT = b'import "messages.proto";' _MESSAGES_IMPORT = b'import "messages.proto";'
......
...@@ -27,14 +27,14 @@ ...@@ -27,14 +27,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Tests of grpc.reflection.v1alpha.reflection.""" """Tests of grpc_reflection.v1alpha.reflection."""
import unittest import unittest
import grpc import grpc
from grpc.framework.foundation import logging_pool from grpc.framework.foundation import logging_pool
from grpc.reflection.v1alpha import reflection from grpc_reflection.v1alpha import reflection
from grpc.reflection.v1alpha import reflection_pb2 from grpc_reflection.v1alpha import reflection_pb2
from google.protobuf import descriptor_pool from google.protobuf import descriptor_pool
from google.protobuf import descriptor_pb2 from google.protobuf import descriptor_pb2
......
# Copyright 2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
__import__('pkg_resources').declare_namespace(__name__)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment