From d24c138e459413d3b93f1a72a93cf90cee958775 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Tue, 20 Sep 2016 13:45:48 -0700 Subject: [PATCH] Moving core into designated package. --- core/README.rst | 20 ++++++ core/google/__init__.py | 22 ++++++ core/google/cloud/__init__.py | 22 ++++++ {google => core/google}/cloud/_helpers.py | 0 {google => core/google}/cloud/client.py | 0 {google => core/google}/cloud/connection.py | 0 {google => core/google}/cloud/credentials.py | 0 .../google}/cloud/environment_vars.py | 0 {google => core/google}/cloud/exceptions.py | 0 {google => core/google}/cloud/iterator.py | 0 {google => core/google}/cloud/operation.py | 0 .../google}/cloud/streaming/__init__.py | 0 .../cloud/streaming/buffered_stream.py | 0 .../google}/cloud/streaming/exceptions.py | 0 .../google}/cloud/streaming/http_wrapper.py | 0 .../google}/cloud/streaming/stream_slice.py | 0 .../google}/cloud/streaming/transfer.py | 0 .../google}/cloud/streaming/util.py | 0 core/setup.py | 72 +++++++++++++++++++ scripts/run_pylint.py | 6 +- scripts/verify_included_modules.py | 23 ++++-- setup.py | 55 +++++++------- tox.ini | 1 + 23 files changed, 186 insertions(+), 35 deletions(-) create mode 100644 core/README.rst create mode 100644 core/google/__init__.py create mode 100644 core/google/cloud/__init__.py rename {google => core/google}/cloud/_helpers.py (100%) rename {google => core/google}/cloud/client.py (100%) rename {google => core/google}/cloud/connection.py (100%) rename {google => core/google}/cloud/credentials.py (100%) rename {google => core/google}/cloud/environment_vars.py (100%) rename {google => core/google}/cloud/exceptions.py (100%) rename {google => core/google}/cloud/iterator.py (100%) rename {google => core/google}/cloud/operation.py (100%) rename {google => core/google}/cloud/streaming/__init__.py (100%) rename {google => core/google}/cloud/streaming/buffered_stream.py (100%) rename {google => core/google}/cloud/streaming/exceptions.py (100%) rename {google => core/google}/cloud/streaming/http_wrapper.py (100%) rename {google => core/google}/cloud/streaming/stream_slice.py (100%) rename {google => core/google}/cloud/streaming/transfer.py (100%) rename {google => core/google}/cloud/streaming/util.py (100%) create mode 100644 core/setup.py diff --git a/core/README.rst b/core/README.rst new file mode 100644 index 0000000000000..d8ec01b781bed --- /dev/null +++ b/core/README.rst @@ -0,0 +1,20 @@ +Core Helpers for Google Cloud Python Client Library +=================================================== + +This library is not meant to stand-alone. Instead it defines +common helpers (e.g. base ``Client`` and ``Connection`` classes) +used by all of the ``google-cloud-*``. + + +- `Homepage`_ +- `API Documentation`_ + +.. _Homepage: https://googlecloudplatform.github.io/google-cloud-python/ +.. _API Documentation: http://googlecloudplatform.github.io/google-cloud-python/ + +Quick Start +----------- + +:: + + $ pip install --upgrade google-cloud-core diff --git a/core/google/__init__.py b/core/google/__init__.py new file mode 100644 index 0000000000000..14aa202c24c19 --- /dev/null +++ b/core/google/__init__.py @@ -0,0 +1,22 @@ +# Copyright 2016 Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Base ``google`` namespace package.""" + +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/core/google/cloud/__init__.py b/core/google/cloud/__init__.py new file mode 100644 index 0000000000000..1768fdd079a25 --- /dev/null +++ b/core/google/cloud/__init__.py @@ -0,0 +1,22 @@ +# Copyright 2014 Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Google Cloud API access in idiomatic Python.""" + +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/google/cloud/_helpers.py b/core/google/cloud/_helpers.py similarity index 100% rename from google/cloud/_helpers.py rename to core/google/cloud/_helpers.py diff --git a/google/cloud/client.py b/core/google/cloud/client.py similarity index 100% rename from google/cloud/client.py rename to core/google/cloud/client.py diff --git a/google/cloud/connection.py b/core/google/cloud/connection.py similarity index 100% rename from google/cloud/connection.py rename to core/google/cloud/connection.py diff --git a/google/cloud/credentials.py b/core/google/cloud/credentials.py similarity index 100% rename from google/cloud/credentials.py rename to core/google/cloud/credentials.py diff --git a/google/cloud/environment_vars.py b/core/google/cloud/environment_vars.py similarity index 100% rename from google/cloud/environment_vars.py rename to core/google/cloud/environment_vars.py diff --git a/google/cloud/exceptions.py b/core/google/cloud/exceptions.py similarity index 100% rename from google/cloud/exceptions.py rename to core/google/cloud/exceptions.py diff --git a/google/cloud/iterator.py b/core/google/cloud/iterator.py similarity index 100% rename from google/cloud/iterator.py rename to core/google/cloud/iterator.py diff --git a/google/cloud/operation.py b/core/google/cloud/operation.py similarity index 100% rename from google/cloud/operation.py rename to core/google/cloud/operation.py diff --git a/google/cloud/streaming/__init__.py b/core/google/cloud/streaming/__init__.py similarity index 100% rename from google/cloud/streaming/__init__.py rename to core/google/cloud/streaming/__init__.py diff --git a/google/cloud/streaming/buffered_stream.py b/core/google/cloud/streaming/buffered_stream.py similarity index 100% rename from google/cloud/streaming/buffered_stream.py rename to core/google/cloud/streaming/buffered_stream.py diff --git a/google/cloud/streaming/exceptions.py b/core/google/cloud/streaming/exceptions.py similarity index 100% rename from google/cloud/streaming/exceptions.py rename to core/google/cloud/streaming/exceptions.py diff --git a/google/cloud/streaming/http_wrapper.py b/core/google/cloud/streaming/http_wrapper.py similarity index 100% rename from google/cloud/streaming/http_wrapper.py rename to core/google/cloud/streaming/http_wrapper.py diff --git a/google/cloud/streaming/stream_slice.py b/core/google/cloud/streaming/stream_slice.py similarity index 100% rename from google/cloud/streaming/stream_slice.py rename to core/google/cloud/streaming/stream_slice.py diff --git a/google/cloud/streaming/transfer.py b/core/google/cloud/streaming/transfer.py similarity index 100% rename from google/cloud/streaming/transfer.py rename to core/google/cloud/streaming/transfer.py diff --git a/google/cloud/streaming/util.py b/core/google/cloud/streaming/util.py similarity index 100% rename from google/cloud/streaming/util.py rename to core/google/cloud/streaming/util.py diff --git a/core/setup.py b/core/setup.py new file mode 100644 index 0000000000000..6fee9e6e8ec29 --- /dev/null +++ b/core/setup.py @@ -0,0 +1,72 @@ +# Copyright 2016 Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from setuptools import setup +from setuptools import find_packages + + +PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__)) + +with open(os.path.join(PACKAGE_ROOT, 'README.rst')) as file_obj: + README = file_obj.read() + +# NOTE: This is duplicated throughout and we should try to +# consolidate. +SETUP_BASE = { + 'author': 'Google Cloud Platform', + 'author_email': 'jjg+google-cloud-python@google.com', + 'scripts': [], + 'url': 'https://github.com/GoogleCloudPlatform/google-cloud-python', + 'license': 'Apache 2.0', + 'platforms': 'Posix; MacOS X; Windows', + 'include_package_data': True, + 'zip_safe': False, + 'classifiers': [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Topic :: Internet', + ], +} + + +REQUIREMENTS = [ + 'httplib2 >= 0.9.1', + 'googleapis-common-protos', + 'oauth2client >= 2.0.1, < 3.0.0', + 'protobuf >= 3.0.0', + 'six', +] + +setup( + name='google-cloud-core', + version='0.19.0', + description='API Client library for Google Cloud: Core Helpers', + long_description=README, + namespace_packages=[ + 'google', + 'google.cloud', + ], + packages=find_packages(), + install_requires=REQUIREMENTS, + **SETUP_BASE +) diff --git a/scripts/run_pylint.py b/scripts/run_pylint.py index 7774b68a77651..183d41e3d7045 100644 --- a/scripts/run_pylint.py +++ b/scripts/run_pylint.py @@ -33,10 +33,11 @@ IGNORED_DIRECTORIES = [ os.path.join('google', 'cloud', 'bigtable', '_generated'), os.path.join('google', 'cloud', 'datastore', '_generated'), - 'scripts/verify_included_modules.py', ] IGNORED_FILES = [ os.path.join('docs', 'conf.py'), +] +IGNORED_POSTFIXES = [ 'setup.py', ] SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__)) @@ -113,6 +114,9 @@ def make_test_rc(base_rc_filename, additions_dict, def valid_filename(filename): """Checks if a file is a Python file and is not ignored.""" + for postfix in IGNORED_POSTFIXES: + if filename.endswith(postfix): + return False for directory in IGNORED_DIRECTORIES: if filename.startswith(directory): return False diff --git a/scripts/verify_included_modules.py b/scripts/verify_included_modules.py index a45774239bc01..fa9d76740a53f 100644 --- a/scripts/verify_included_modules.py +++ b/scripts/verify_included_modules.py @@ -56,6 +56,10 @@ 'google.cloud.vision.__init__', 'google.cloud.vision.fixtures', ]) +PACKAGES = ( + '', + 'core', +) class SphinxApp(object): @@ -126,6 +130,11 @@ def main(build_root='_build'): :param build_root: The root of the directory where docs are built into. Defaults to ``_build``. """ + if build_root is None: + parser = get_parser() + args = parser.parse_args() + build_root = args.build_root + object_inventory_relpath = os.path.join(build_root, 'html', 'objects.inv') mock_uri = '' @@ -133,10 +142,12 @@ def main(build_root='_build'): object_inventory_relpath) sphinx_mods = set(inventory['py:module'].keys()) - library_dir = os.path.join(BASE_DIR, 'google', 'cloud') - public_mods = get_public_modules(library_dir, - base_package='google.cloud') - public_mods = set(public_mods) + public_mods = set() + for package in PACKAGES: + library_dir = os.path.join(BASE_DIR, package, 'google', 'cloud') + package_mods = get_public_modules(library_dir, + base_package='google.cloud') + public_mods.update(package_mods) if not sphinx_mods <= public_mods: unexpected_mods = sphinx_mods - public_mods @@ -172,6 +183,4 @@ def get_parser(): if __name__ == '__main__': - parser = get_parser() - args = parser.parse_args() - main(build_root=args.build_root) + main(build_root=None) diff --git a/setup.py b/setup.py index f1e9a2eac826f..a2f3a425393bb 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,7 @@ import os -import sys -from setuptools import setup from setuptools import find_packages +from setuptools import setup PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) @@ -10,13 +9,34 @@ with open(os.path.join(PROJECT_ROOT, 'README.rst')) as file_obj: README = file_obj.read() +# NOTE: This is duplicated throughout and we should try to +# consolidate. +SETUP_BASE = { + 'author': 'Google Cloud Platform', + 'author_email': 'jjg+google-cloud-python@google.com', + 'scripts': [], + 'url': 'https://github.com/GoogleCloudPlatform/google-cloud-python', + 'license': 'Apache 2.0', + 'platforms': 'Posix; MacOS X; Windows', + 'include_package_data': True, + 'zip_safe': False, + 'classifiers': [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Topic :: Internet', + ], +} + REQUIREMENTS = [ - 'httplib2 >= 0.9.1', - 'googleapis-common-protos', - 'oauth2client >= 2.0.1', - 'protobuf >= 3.0.0', - 'six', + 'google-cloud-core', ] GRPC_PACKAGES = [ @@ -36,31 +56,12 @@ name='google-cloud', version='0.19.0', description='API Client library for Google Cloud', - author='Google Cloud Platform', - author_email='jjg+google-cloud-python@google.com', long_description=README, - scripts=[], - url='https://github.com/GoogleCloudPlatform/google-cloud-python', namespace_packages=[ 'google', 'google.cloud', ], packages=find_packages(), - license='Apache 2.0', - platforms='Posix; MacOS X; Windows', - include_package_data=True, - zip_safe=False, install_requires=REQUIREMENTS, - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Topic :: Internet', - ] + **SETUP_BASE ) diff --git a/tox.ini b/tox.ini index d0cc47ded48d7..479103c7c525a 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,7 @@ envlist = [testing] deps = + {toxinidir}/core pytest covercmd = py.test --quiet \