From c6558b9872f9c07fa5f955e7726f571411f7be28 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 26 Sep 2016 12:46:48 -0700 Subject: [PATCH 1/3] Moving all pubsub files into subdirectory. Done via: $ mkdir -p pubsub/google/cloud $ cp google/__init__.py pubsub/google/__init__.py $ git add pubsub/google/__init__.py $ cp google/cloud/__init__.py pubsub/google/cloud/__init__.py $ git add pubsub/google/cloud/__init__.py $ git mv google/cloud/pubsub pubsub/google/cloud/pubsub $ git mv unit_tests/pubsub pubsub/unit_tests --- pubsub/google/__init__.py | 20 +++++++++++++++++++ pubsub/google/cloud/__init__.py | 20 +++++++++++++++++++ .../google}/cloud/pubsub/__init__.py | 0 .../google}/cloud/pubsub/_gax.py | 0 .../google}/cloud/pubsub/_helpers.py | 0 .../google}/cloud/pubsub/client.py | 0 .../google}/cloud/pubsub/connection.py | 0 {google => pubsub/google}/cloud/pubsub/iam.py | 0 .../google}/cloud/pubsub/message.py | 0 .../google}/cloud/pubsub/subscription.py | 0 .../google}/cloud/pubsub/topic.py | 0 .../pubsub => pubsub/unit_tests}/__init__.py | 0 .../pubsub => pubsub/unit_tests}/test__gax.py | 0 .../unit_tests}/test__helpers.py | 0 .../unit_tests}/test_client.py | 0 .../unit_tests}/test_connection.py | 0 .../pubsub => pubsub/unit_tests}/test_iam.py | 0 .../unit_tests}/test_message.py | 0 .../unit_tests}/test_subscription.py | 0 .../unit_tests}/test_topic.py | 0 20 files changed, 40 insertions(+) create mode 100644 pubsub/google/__init__.py create mode 100644 pubsub/google/cloud/__init__.py rename {google => pubsub/google}/cloud/pubsub/__init__.py (100%) rename {google => pubsub/google}/cloud/pubsub/_gax.py (100%) rename {google => pubsub/google}/cloud/pubsub/_helpers.py (100%) rename {google => pubsub/google}/cloud/pubsub/client.py (100%) rename {google => pubsub/google}/cloud/pubsub/connection.py (100%) rename {google => pubsub/google}/cloud/pubsub/iam.py (100%) rename {google => pubsub/google}/cloud/pubsub/message.py (100%) rename {google => pubsub/google}/cloud/pubsub/subscription.py (100%) rename {google => pubsub/google}/cloud/pubsub/topic.py (100%) rename {unit_tests/pubsub => pubsub/unit_tests}/__init__.py (100%) rename {unit_tests/pubsub => pubsub/unit_tests}/test__gax.py (100%) rename {unit_tests/pubsub => pubsub/unit_tests}/test__helpers.py (100%) rename {unit_tests/pubsub => pubsub/unit_tests}/test_client.py (100%) rename {unit_tests/pubsub => pubsub/unit_tests}/test_connection.py (100%) rename {unit_tests/pubsub => pubsub/unit_tests}/test_iam.py (100%) rename {unit_tests/pubsub => pubsub/unit_tests}/test_message.py (100%) rename {unit_tests/pubsub => pubsub/unit_tests}/test_subscription.py (100%) rename {unit_tests/pubsub => pubsub/unit_tests}/test_topic.py (100%) diff --git a/pubsub/google/__init__.py b/pubsub/google/__init__.py new file mode 100644 index 000000000000..b2b833373882 --- /dev/null +++ b/pubsub/google/__init__.py @@ -0,0 +1,20 @@ +# Copyright 2016 Google Inc. +# +# 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. + +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/pubsub/google/cloud/__init__.py b/pubsub/google/cloud/__init__.py new file mode 100644 index 000000000000..8ac7b74af136 --- /dev/null +++ b/pubsub/google/cloud/__init__.py @@ -0,0 +1,20 @@ +# Copyright 2014 Google Inc. +# +# 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. + +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/google/cloud/pubsub/__init__.py b/pubsub/google/cloud/pubsub/__init__.py similarity index 100% rename from google/cloud/pubsub/__init__.py rename to pubsub/google/cloud/pubsub/__init__.py diff --git a/google/cloud/pubsub/_gax.py b/pubsub/google/cloud/pubsub/_gax.py similarity index 100% rename from google/cloud/pubsub/_gax.py rename to pubsub/google/cloud/pubsub/_gax.py diff --git a/google/cloud/pubsub/_helpers.py b/pubsub/google/cloud/pubsub/_helpers.py similarity index 100% rename from google/cloud/pubsub/_helpers.py rename to pubsub/google/cloud/pubsub/_helpers.py diff --git a/google/cloud/pubsub/client.py b/pubsub/google/cloud/pubsub/client.py similarity index 100% rename from google/cloud/pubsub/client.py rename to pubsub/google/cloud/pubsub/client.py diff --git a/google/cloud/pubsub/connection.py b/pubsub/google/cloud/pubsub/connection.py similarity index 100% rename from google/cloud/pubsub/connection.py rename to pubsub/google/cloud/pubsub/connection.py diff --git a/google/cloud/pubsub/iam.py b/pubsub/google/cloud/pubsub/iam.py similarity index 100% rename from google/cloud/pubsub/iam.py rename to pubsub/google/cloud/pubsub/iam.py diff --git a/google/cloud/pubsub/message.py b/pubsub/google/cloud/pubsub/message.py similarity index 100% rename from google/cloud/pubsub/message.py rename to pubsub/google/cloud/pubsub/message.py diff --git a/google/cloud/pubsub/subscription.py b/pubsub/google/cloud/pubsub/subscription.py similarity index 100% rename from google/cloud/pubsub/subscription.py rename to pubsub/google/cloud/pubsub/subscription.py diff --git a/google/cloud/pubsub/topic.py b/pubsub/google/cloud/pubsub/topic.py similarity index 100% rename from google/cloud/pubsub/topic.py rename to pubsub/google/cloud/pubsub/topic.py diff --git a/unit_tests/pubsub/__init__.py b/pubsub/unit_tests/__init__.py similarity index 100% rename from unit_tests/pubsub/__init__.py rename to pubsub/unit_tests/__init__.py diff --git a/unit_tests/pubsub/test__gax.py b/pubsub/unit_tests/test__gax.py similarity index 100% rename from unit_tests/pubsub/test__gax.py rename to pubsub/unit_tests/test__gax.py diff --git a/unit_tests/pubsub/test__helpers.py b/pubsub/unit_tests/test__helpers.py similarity index 100% rename from unit_tests/pubsub/test__helpers.py rename to pubsub/unit_tests/test__helpers.py diff --git a/unit_tests/pubsub/test_client.py b/pubsub/unit_tests/test_client.py similarity index 100% rename from unit_tests/pubsub/test_client.py rename to pubsub/unit_tests/test_client.py diff --git a/unit_tests/pubsub/test_connection.py b/pubsub/unit_tests/test_connection.py similarity index 100% rename from unit_tests/pubsub/test_connection.py rename to pubsub/unit_tests/test_connection.py diff --git a/unit_tests/pubsub/test_iam.py b/pubsub/unit_tests/test_iam.py similarity index 100% rename from unit_tests/pubsub/test_iam.py rename to pubsub/unit_tests/test_iam.py diff --git a/unit_tests/pubsub/test_message.py b/pubsub/unit_tests/test_message.py similarity index 100% rename from unit_tests/pubsub/test_message.py rename to pubsub/unit_tests/test_message.py diff --git a/unit_tests/pubsub/test_subscription.py b/pubsub/unit_tests/test_subscription.py similarity index 100% rename from unit_tests/pubsub/test_subscription.py rename to pubsub/unit_tests/test_subscription.py diff --git a/unit_tests/pubsub/test_topic.py b/pubsub/unit_tests/test_topic.py similarity index 100% rename from unit_tests/pubsub/test_topic.py rename to pubsub/unit_tests/test_topic.py From ddf2b34538d9be0fb3f2a8e742e72af9fcb090e6 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 26 Sep 2016 12:46:48 -0700 Subject: [PATCH 2/3] Making pubsub subpackage into a proper package. - Adding README, setup.py, MANIFEST.in, .coveragerc and tox.ini - Adding google-cloud-pubsub as a dependency to the umbrella package - Adding the pubsub subdirectory into the list of packages for verifying the docs - Incorporating the pubsub subdirectory into the umbrella coverage report - Adding the pubsub only tox tests to the Travis config - Adding {toxinidir}/../core as a dependency for the pubsub tox config --- .travis.yml | 3 ++ pubsub/.coveragerc | 11 +++++ pubsub/MANIFEST.in | 4 ++ pubsub/README.rst | 61 +++++++++++++++++++++++++ pubsub/setup.py | 72 ++++++++++++++++++++++++++++++ pubsub/tox.ini | 30 +++++++++++++ scripts/verify_included_modules.py | 1 + setup.py | 1 + tox.ini | 7 +++ 9 files changed, 190 insertions(+) create mode 100644 pubsub/.coveragerc create mode 100644 pubsub/MANIFEST.in create mode 100644 pubsub/README.rst create mode 100644 pubsub/setup.py create mode 100644 pubsub/tox.ini diff --git a/.travis.yml b/.travis.yml index c51faf9b92b5..63cb65de8166 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,12 +11,14 @@ script: - (cd storage && tox -e py27) - (cd datastore && tox -e py27) - (cd bigquery && tox -e py27) + - (cd pubsub && tox -e py27) - tox -e py34 - (cd core && tox -e py34) - (cd bigtable && tox -e py34) - (cd storage && tox -e py34) - (cd datastore && tox -e py34) - (cd bigquery && tox -e py34) + - (cd pubsub && tox -e py34) - tox -e lint - tox -e cover - (cd core && tox -e cover) @@ -24,6 +26,7 @@ script: - (cd storage && tox -e cover) - (cd datastore && tox -e cover) - (cd bigquery && tox -e cover) + - (cd pubsub && tox -e cover) - tox -e system-tests - tox -e system-tests3 - scripts/update_docs.sh diff --git a/pubsub/.coveragerc b/pubsub/.coveragerc new file mode 100644 index 000000000000..a54b99aa14b7 --- /dev/null +++ b/pubsub/.coveragerc @@ -0,0 +1,11 @@ +[run] +branch = True + +[report] +fail_under = 100 +show_missing = True +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ diff --git a/pubsub/MANIFEST.in b/pubsub/MANIFEST.in new file mode 100644 index 000000000000..cb3a2b9ef4fa --- /dev/null +++ b/pubsub/MANIFEST.in @@ -0,0 +1,4 @@ +include README.rst +graft google +graft unit_tests +global-exclude *.pyc diff --git a/pubsub/README.rst b/pubsub/README.rst new file mode 100644 index 000000000000..201a61e3eaf2 --- /dev/null +++ b/pubsub/README.rst @@ -0,0 +1,61 @@ +Python Client for Google Cloud Pub / Sub +======================================== + + Python idiomatic client for `Google Cloud Pub / Sub`_ + +.. _Google Cloud Pub / Sub: https://cloud.google.com/pubsub/docs + +- `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-pubsub + +Authentication +-------------- + +With ``google-cloud-python`` we try to make authentication as painless as +possible. Check out the `Authentication section`_ in our documentation to +learn more. You may also find the `authentication document`_ shared by all +the ``google-cloud-*`` libraries to be helpful. + +.. _Authentication section: http://google-cloud-python.readthedocs.io/en/latest/google-cloud-auth.html +.. _authentication document: https://github.com/GoogleCloudPlatform/gcloud-common/tree/master/authentication + +Using the API +------------- + +Google `Cloud Pub/Sub`_ (`Pub/Sub API docs`_) is designed to provide reliable, +many-to-many, asynchronous messaging between applications. Publisher +applications can send messages to a ``topic`` and other applications can +subscribe to that topic to receive the messages. By decoupling senders and +receivers, Google Cloud Pub/Sub allows developers to communicate between +independently written applications. + +.. _Cloud Pub/Sub: https://cloud.google.com/pubsub/docs +.. _Pub/Sub API docs: https://cloud.google.com/pubsub/reference/rest/ + +See the ``google-cloud-python`` API `Pub/Sub documentation`_ to learn how to connect +to Cloud Pub/Sub using this Client Library. + +.. _Pub/Sub documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/pubsub-usage.html + +To get started with this API, you'll need to create + +.. code:: python + + from google.cloud import pubsub + + client = pubsub.Client() + topic = client.topic('topic_name') + topic.create() + + topic.publish('this is the message_payload', + attr1='value1', attr2='value2') diff --git a/pubsub/setup.py b/pubsub/setup.py new file mode 100644 index 000000000000..d60b3f27b7b6 --- /dev/null +++ b/pubsub/setup.py @@ -0,0 +1,72 @@ +# Copyright 2016 Google Inc. +# +# 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 find_packages +from setuptools import setup + + +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 = [ + 'google-cloud-core', + 'grpcio >= 1.0.0', + 'google-gax >= 0.14.1, < 0.15dev', + 'gapic-google-pubsub-v1 >= 0.9.0, < 0.10dev', + 'grpc-google-pubsub-v1 >= 0.9.0, < 0.10dev', +] + +setup( + name='google-cloud-pubsub', + version='0.20.0dev', + description='Python Client for Google Cloud Pub/Sub', + long_description=README, + namespace_packages=[ + 'google', + 'google.cloud', + ], + packages=find_packages(), + install_requires=REQUIREMENTS, + **SETUP_BASE +) diff --git a/pubsub/tox.ini b/pubsub/tox.ini new file mode 100644 index 000000000000..9a9990704fbe --- /dev/null +++ b/pubsub/tox.ini @@ -0,0 +1,30 @@ +[tox] +envlist = + py27,py34,py35,cover + +[testing] +deps = + {toxinidir}/../core + pytest +covercmd = + py.test --quiet \ + --cov=google.cloud.pubsub \ + --cov=unit_tests \ + --cov-config {toxinidir}/.coveragerc \ + unit_tests + +[testenv] +commands = + py.test --quiet {posargs} unit_tests +deps = + {[testing]deps} + +[testenv:cover] +basepython = + python2.7 +commands = + {[testing]covercmd} +deps = + {[testenv]deps} + coverage + pytest-cov diff --git a/scripts/verify_included_modules.py b/scripts/verify_included_modules.py index 8bd4e73d65f8..358e66b3ddca 100644 --- a/scripts/verify_included_modules.py +++ b/scripts/verify_included_modules.py @@ -63,6 +63,7 @@ 'bigtable', 'core', 'datastore', + 'pubsub', 'storage', ) diff --git a/setup.py b/setup.py index 26b52c5b9f5f..39c6c001dad6 100644 --- a/setup.py +++ b/setup.py @@ -54,6 +54,7 @@ 'google-cloud-bigtable', 'google-cloud-core', 'google-cloud-datastore', + 'google-cloud-pubsub', 'google-cloud-storage', ] diff --git a/tox.ini b/tox.ini index c7bb3d36190b..f74fc93b945b 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,7 @@ deps = {toxinidir}/storage {toxinidir}/datastore {toxinidir}/bigquery + {toxinidir}/pubsub pytest covercmd = py.test --quiet \ @@ -46,6 +47,12 @@ covercmd = --cov-append \ --cov-config {toxinidir}/.coveragerc \ bigquery/unit_tests + py.test --quiet \ + --cov=google.cloud \ + --cov=unit_tests \ + --cov-append \ + --cov-config {toxinidir}/.coveragerc \ + pubsub/unit_tests coverage report --show-missing --fail-under=100 [testenv] From 27380f94ff7983dac6aa9caa319407c3222bcf83 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 26 Sep 2016 12:47:10 -0700 Subject: [PATCH 3/3] Remove Pub / Sub deps from setup.py. --- setup.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/setup.py b/setup.py index 39c6c001dad6..a43a6fe9051c 100644 --- a/setup.py +++ b/setup.py @@ -61,8 +61,6 @@ GRPC_PACKAGES = [ 'grpcio >= 1.0.0', 'google-gax >= 0.14.1, < 0.15dev', - 'gapic-google-pubsub-v1 >= 0.9.0, < 0.10dev', - 'grpc-google-pubsub-v1 >= 0.9.0, < 0.10dev', 'gapic-google-logging-v2 >= 0.9.0, < 0.10dev', 'grpc-google-logging-v2 >= 0.9.0, < 0.10dev', ]