Merge pull request #9071 from soltanmm-google/taking-tradition-as-law-is-a-dangerous-idea

Un-namespace Python packages
pull/8925/merge
Masood Malekghassemi 8 years ago committed by GitHub
commit 343395b005
  1. 2
      examples/python/multiplex/run_codegen.py
  2. 2
      examples/python/route_guide/run_codegen.py
  3. 22
      src/python/grpcio/grpc/__init__.py
  4. 30
      src/python/grpcio_health_checking/grpc/__init__.py
  5. 0
      src/python/grpcio_health_checking/grpc_health/__init__.py
  6. 0
      src/python/grpcio_health_checking/grpc_health/v1/__init__.py
  7. 2
      src/python/grpcio_health_checking/grpc_health/v1/health.py
  8. 4
      src/python/grpcio_health_checking/health_commands.py
  9. 1
      src/python/grpcio_health_checking/setup.py
  10. 30
      src/python/grpcio_reflection/grpc/__init__.py
  11. 0
      src/python/grpcio_reflection/grpc_reflection/__init__.py
  12. 0
      src/python/grpcio_reflection/grpc_reflection/v1alpha/__init__.py
  13. 2
      src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py
  14. 4
      src/python/grpcio_reflection/reflection_commands.py
  15. 1
      src/python/grpcio_reflection/setup.py
  16. 4
      src/python/grpcio_tests/commands.py
  17. 4
      src/python/grpcio_tests/setup.py
  18. 6
      src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
  19. 2
      src/python/grpcio_tests/tests/protoc_plugin/_split_definitions_test.py
  20. 6
      src/python/grpcio_tests/tests/reflection/_reflection_servicer_test.py
  21. 30
      tools/distrib/python/grpcio_tools/grpc/__init__.py
  22. 0
      tools/distrib/python/grpcio_tools/grpc_tools/__init__.py
  23. 2
      tools/distrib/python/grpcio_tools/grpc_tools/_protoc_compiler.pyx
  24. 4
      tools/distrib/python/grpcio_tools/grpc_tools/command.py
  25. 2
      tools/distrib/python/grpcio_tools/grpc_tools/main.cc
  26. 0
      tools/distrib/python/grpcio_tools/grpc_tools/main.h
  27. 2
      tools/distrib/python/grpcio_tools/grpc_tools/protoc.py
  28. 11
      tools/distrib/python/grpcio_tools/setup.py

@ -29,7 +29,7 @@
"""Generates protocol messages and gRPC stubs."""
from grpc.tools import protoc
from grpc_tools import protoc
protoc.main(
(

@ -29,7 +29,7 @@
"""Runs protoc with the gRPC plugin to generate messages and gRPC stubs."""
from grpc.tools import protoc
from grpc_tools import protoc
protoc.main(
(

@ -31,6 +31,7 @@
import abc
import enum
import sys
import six
@ -1342,3 +1343,24 @@ __all__ = (
'secure_channel',
'server',
)
############################### Extension Shims ################################
# Here to maintain backwards compatibility; avoid using these in new code!
try:
import grpc_tools
sys.modules.update({'grpc.tools': grpc_tools})
except ImportError:
pass
try:
import grpc_health
sys.modules.update({'grpc.health': grpc_health})
except ImportError:
pass
try:
import grpc_reflection
sys.modules.update({'grpc.reflection': grpc_reflection})
except ImportError:
pass

@ -1,30 +0,0 @@
# 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
import grpc
from grpc.health.v1 import health_pb2
from grpc_health.v1 import health_pb2
class HealthServicer(health_pb2.HealthServicer):

@ -54,7 +54,7 @@ class CopyProtoModules(setuptools.Command):
if os.path.isfile(HEALTH_PROTO):
shutil.copyfile(
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):
@ -74,5 +74,5 @@ class BuildPackageProtos(setuptools.Command):
# 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
# there).
from grpc.tools import command
from grpc_tools import command
command.build_package_protos(self.distribution.package_dir[''])

@ -66,7 +66,6 @@ setuptools.setup(
license='3-clause BSD',
package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages('.'),
namespace_packages=['grpc'],
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS

@ -1,30 +0,0 @@
# 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
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool
from grpc.reflection.v1alpha import reflection_pb2
from grpc_reflection.v1alpha import reflection_pb2
_POOL = descriptor_pool.Default()

@ -54,7 +54,7 @@ class CopyProtoModules(setuptools.Command):
if os.path.isfile(HEALTH_PROTO):
shutil.copyfile(
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):
@ -74,5 +74,5 @@ class BuildPackageProtos(setuptools.Command):
# 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
# there).
from grpc.tools import command
from grpc_tools import command
command.build_package_protos(self.distribution.package_dir[''])

@ -66,7 +66,6 @@ setuptools.setup(
license='3-clause BSD',
package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages('.'),
namespace_packages=['grpc'],
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS

@ -100,7 +100,7 @@ class BuildProtoModules(setuptools.Command):
pass
def run(self):
import grpc.tools.protoc as protoc
import grpc_tools.protoc as protoc
include_regex = re.compile(self.include)
exclude_regex = re.compile(self.exclude) if self.exclude else None
@ -116,7 +116,7 @@ class BuildProtoModules(setuptools.Command):
# but we currently have name conflicts in src/proto
for path in paths:
command = [
'grpc.tools.protoc',
'grpc_tools.protoc',
'-I {}'.format(PROTO_STEM),
'--python_out={}'.format(PROTO_STEM),
'--grpc_python_out={}'.format(PROTO_STEM),

@ -35,7 +35,7 @@ import sys
import setuptools
import grpc.tools.command
import grpc_tools.command
PY3 = sys.version_info.major == 3
@ -68,7 +68,7 @@ COMMAND_CLASS = {
# Run `preprocess` *before* doing any packaging!
'preprocess': commands.GatherProto,
'build_package_protos': grpc.tools.command.BuildPackageProtos,
'build_package_protos': grpc_tools.command.BuildPackageProtos,
'build_py': commands.BuildPy,
'run_interop': commands.RunInterop,
'test_lite': commands.TestLite

@ -27,14 +27,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# 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 grpc
from grpc.framework.foundation import logging_pool
from grpc.health.v1 import health
from grpc.health.v1 import health_pb2
from grpc_health.v1 import health
from grpc_health.v1 import health_pb2
from tests.unit.framework.common import test_constants

@ -44,7 +44,7 @@ import threading
import unittest
import grpc
from grpc.tools import protoc
from grpc_tools import protoc
from tests.unit.framework.common import test_constants
_MESSAGES_IMPORT = b'import "messages.proto";'

@ -27,14 +27,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# 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 grpc
from grpc.framework.foundation import logging_pool
from grpc.reflection.v1alpha import reflection
from grpc.reflection.v1alpha import reflection_pb2
from grpc_reflection.v1alpha import reflection
from grpc_reflection.v1alpha import reflection_pb2
from google.protobuf import descriptor_pool
from google.protobuf import descriptor_pb2

@ -1,30 +0,0 @@
# 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__)

@ -29,7 +29,7 @@
from libc cimport stdlib
cdef extern from "grpc/tools/main.h":
cdef extern from "grpc_tools/main.h":
int protoc_main(int argc, char *argv[])
def run_main(list args not None):

@ -33,7 +33,7 @@ import sys
import setuptools
from grpc.tools import protoc
from grpc_tools import protoc
def build_package_protos(package_root):
@ -45,7 +45,7 @@ def build_package_protos(package_root):
proto_files.append(os.path.abspath(os.path.join(root, filename)))
well_known_protos_include = pkg_resources.resource_filename(
'grpc.tools', '_proto')
'grpc_tools', '_proto')
for proto_file in proto_files:
command = [

@ -32,7 +32,7 @@
#include "src/compiler/python_generator.h"
#include "grpc/tools/main.h"
#include "grpc_tools/main.h"
int protoc_main(int argc, char* argv[]) {
google::protobuf::compiler::CommandLineInterface cli;

@ -32,7 +32,7 @@
import pkg_resources
import sys
from grpc.tools import _protoc_compiler
from grpc_tools import _protoc_compiler
def main(command_arguments):
"""Run the protocol buffer compiler with the given command-line arguments.

@ -108,7 +108,7 @@ PROTO_FILES = [
CC_INCLUDE = os.path.normpath(protoc_lib_deps.CC_INCLUDE)
PROTO_INCLUDE = os.path.normpath(protoc_lib_deps.PROTO_INCLUDE)
GRPC_PYTHON_TOOLS_PACKAGE = 'grpc.tools'
GRPC_PYTHON_TOOLS_PACKAGE = 'grpc_tools'
GRPC_PYTHON_PROTO_RESOURCES_NAME = '_proto'
DEFINE_MACROS = ()
@ -154,16 +154,16 @@ def package_data():
def extension_modules():
if BUILD_WITH_CYTHON:
plugin_sources = [os.path.join('grpc', 'tools', '_protoc_compiler.pyx')]
plugin_sources = [os.path.join('grpc_tools', '_protoc_compiler.pyx')]
else:
plugin_sources = [os.path.join('grpc', 'tools', '_protoc_compiler.cpp')]
plugin_sources = [os.path.join('grpc_tools', '_protoc_compiler.cpp')]
plugin_sources += [
os.path.join('grpc', 'tools', 'main.cc'),
os.path.join('grpc_tools', 'main.cc'),
os.path.join('grpc_root', 'src', 'compiler', 'python_generator.cc')] + [
os.path.join(CC_INCLUDE, cc_file)
for cc_file in CC_FILES]
plugin_ext = extension.Extension(
name='grpc.tools._protoc_compiler',
name='grpc_tools._protoc_compiler',
sources=plugin_sources,
include_dirs=[
'.',
@ -189,7 +189,6 @@ setuptools.setup(
license='3-clause BSD',
ext_modules=extension_modules(),
packages=setuptools.find_packages('.'),
namespace_packages=['grpc'],
install_requires=[
'protobuf>=3.0.0',
'grpcio>={version}'.format(version=grpc_version.VERSION),

Loading…
Cancel
Save