From dec4aa16814eccb22a4131b3e933289a87f6eb71 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 26 Sep 2016 12:35:57 -0700 Subject: [PATCH 1/2] Moving all storage files into subdirectory. Done via: $ mkdir -p storage/google/cloud $ cp google/__init__.py storage/google/__init__.py $ git add storage/google/__init__.py $ cp google/cloud/__init__.py storage/google/cloud/__init__.py $ git add storage/google/cloud/__init__.py $ git mv google/cloud/storage storage/google/cloud/storage $ git mv unit_tests/storage storage/unit_tests --- storage/google/__init__.py | 20 +++++++++++++++++++ storage/google/cloud/__init__.py | 20 +++++++++++++++++++ .../google}/cloud/storage/__init__.py | 0 .../google}/cloud/storage/_helpers.py | 0 .../google}/cloud/storage/acl.py | 0 .../google}/cloud/storage/batch.py | 0 .../google}/cloud/storage/blob.py | 0 .../google}/cloud/storage/bucket.py | 0 .../google}/cloud/storage/client.py | 0 .../google}/cloud/storage/connection.py | 0 .../unit_tests}/__init__.py | 0 .../unit_tests}/test__helpers.py | 0 .../unit_tests}/test_acl.py | 0 .../unit_tests}/test_batch.py | 0 .../unit_tests}/test_blob.py | 0 .../unit_tests}/test_bucket.py | 0 .../unit_tests}/test_client.py | 0 .../unit_tests}/test_connection.py | 0 18 files changed, 40 insertions(+) create mode 100644 storage/google/__init__.py create mode 100644 storage/google/cloud/__init__.py rename {google => storage/google}/cloud/storage/__init__.py (100%) rename {google => storage/google}/cloud/storage/_helpers.py (100%) rename {google => storage/google}/cloud/storage/acl.py (100%) rename {google => storage/google}/cloud/storage/batch.py (100%) rename {google => storage/google}/cloud/storage/blob.py (100%) rename {google => storage/google}/cloud/storage/bucket.py (100%) rename {google => storage/google}/cloud/storage/client.py (100%) rename {google => storage/google}/cloud/storage/connection.py (100%) rename {unit_tests/storage => storage/unit_tests}/__init__.py (100%) rename {unit_tests/storage => storage/unit_tests}/test__helpers.py (100%) rename {unit_tests/storage => storage/unit_tests}/test_acl.py (100%) rename {unit_tests/storage => storage/unit_tests}/test_batch.py (100%) rename {unit_tests/storage => storage/unit_tests}/test_blob.py (100%) rename {unit_tests/storage => storage/unit_tests}/test_bucket.py (100%) rename {unit_tests/storage => storage/unit_tests}/test_client.py (100%) rename {unit_tests/storage => storage/unit_tests}/test_connection.py (100%) diff --git a/storage/google/__init__.py b/storage/google/__init__.py new file mode 100644 index 000000000000..b2b833373882 --- /dev/null +++ b/storage/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/storage/google/cloud/__init__.py b/storage/google/cloud/__init__.py new file mode 100644 index 000000000000..8ac7b74af136 --- /dev/null +++ b/storage/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/storage/__init__.py b/storage/google/cloud/storage/__init__.py similarity index 100% rename from google/cloud/storage/__init__.py rename to storage/google/cloud/storage/__init__.py diff --git a/google/cloud/storage/_helpers.py b/storage/google/cloud/storage/_helpers.py similarity index 100% rename from google/cloud/storage/_helpers.py rename to storage/google/cloud/storage/_helpers.py diff --git a/google/cloud/storage/acl.py b/storage/google/cloud/storage/acl.py similarity index 100% rename from google/cloud/storage/acl.py rename to storage/google/cloud/storage/acl.py diff --git a/google/cloud/storage/batch.py b/storage/google/cloud/storage/batch.py similarity index 100% rename from google/cloud/storage/batch.py rename to storage/google/cloud/storage/batch.py diff --git a/google/cloud/storage/blob.py b/storage/google/cloud/storage/blob.py similarity index 100% rename from google/cloud/storage/blob.py rename to storage/google/cloud/storage/blob.py diff --git a/google/cloud/storage/bucket.py b/storage/google/cloud/storage/bucket.py similarity index 100% rename from google/cloud/storage/bucket.py rename to storage/google/cloud/storage/bucket.py diff --git a/google/cloud/storage/client.py b/storage/google/cloud/storage/client.py similarity index 100% rename from google/cloud/storage/client.py rename to storage/google/cloud/storage/client.py diff --git a/google/cloud/storage/connection.py b/storage/google/cloud/storage/connection.py similarity index 100% rename from google/cloud/storage/connection.py rename to storage/google/cloud/storage/connection.py diff --git a/unit_tests/storage/__init__.py b/storage/unit_tests/__init__.py similarity index 100% rename from unit_tests/storage/__init__.py rename to storage/unit_tests/__init__.py diff --git a/unit_tests/storage/test__helpers.py b/storage/unit_tests/test__helpers.py similarity index 100% rename from unit_tests/storage/test__helpers.py rename to storage/unit_tests/test__helpers.py diff --git a/unit_tests/storage/test_acl.py b/storage/unit_tests/test_acl.py similarity index 100% rename from unit_tests/storage/test_acl.py rename to storage/unit_tests/test_acl.py diff --git a/unit_tests/storage/test_batch.py b/storage/unit_tests/test_batch.py similarity index 100% rename from unit_tests/storage/test_batch.py rename to storage/unit_tests/test_batch.py diff --git a/unit_tests/storage/test_blob.py b/storage/unit_tests/test_blob.py similarity index 100% rename from unit_tests/storage/test_blob.py rename to storage/unit_tests/test_blob.py diff --git a/unit_tests/storage/test_bucket.py b/storage/unit_tests/test_bucket.py similarity index 100% rename from unit_tests/storage/test_bucket.py rename to storage/unit_tests/test_bucket.py diff --git a/unit_tests/storage/test_client.py b/storage/unit_tests/test_client.py similarity index 100% rename from unit_tests/storage/test_client.py rename to storage/unit_tests/test_client.py diff --git a/unit_tests/storage/test_connection.py b/storage/unit_tests/test_connection.py similarity index 100% rename from unit_tests/storage/test_connection.py rename to storage/unit_tests/test_connection.py From b01ffb4c36b972998f0f6dc56329e231fa3da7bf Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 26 Sep 2016 12:35:57 -0700 Subject: [PATCH 2/2] Making storage subpackage into a proper package. - Adding README, setup.py, MANIFEST.in, .coveragerc and tox.ini - Adding google-cloud-storage as a dependency to the umbrella package - Adding the storage subdirectory into the list of packages for verifying the docs - Incorporating the storage subdirectory into the umbrella coverage report - Adding the storage only tox tests to the Travis config - Adding {toxinidir}/../core as a dependency for the storage tox config --- .travis.yml | 3 ++ scripts/verify_included_modules.py | 1 + setup.py | 3 +- storage/.coveragerc | 11 +++++ storage/MANIFEST.in | 4 ++ storage/README.rst | 64 ++++++++++++++++++++++++++++ storage/setup.py | 68 ++++++++++++++++++++++++++++++ storage/tox.ini | 30 +++++++++++++ tox.ini | 7 +++ 9 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 storage/.coveragerc create mode 100644 storage/MANIFEST.in create mode 100644 storage/README.rst create mode 100644 storage/setup.py create mode 100644 storage/tox.ini diff --git a/.travis.yml b/.travis.yml index aadc6de8d8ad..f0a3ab1c5756 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,13 +8,16 @@ script: - tox -e py27 - (cd core && tox -e py27) - (cd bigtable && tox -e py27) + - (cd storage && tox -e py27) - tox -e py34 - (cd core && tox -e py34) - (cd bigtable && tox -e py34) + - (cd storage && tox -e py34) - tox -e lint - tox -e cover - (cd core && tox -e cover) - (cd bigtable && tox -e cover) + - (cd storage && tox -e cover) - tox -e system-tests - tox -e system-tests3 - scripts/update_docs.sh diff --git a/scripts/verify_included_modules.py b/scripts/verify_included_modules.py index 7bde7e5949bb..68829f961b8f 100644 --- a/scripts/verify_included_modules.py +++ b/scripts/verify_included_modules.py @@ -61,6 +61,7 @@ '', 'bigtable', 'core', + 'storage', ) diff --git a/setup.py b/setup.py index 598e4fd7d13a..1bcebe10e990 100644 --- a/setup.py +++ b/setup.py @@ -50,8 +50,9 @@ REQUIREMENTS = [ - 'google-cloud-core', 'google-cloud-bigtable', + 'google-cloud-core', + 'google-cloud-storage', ] GRPC_PACKAGES = [ diff --git a/storage/.coveragerc b/storage/.coveragerc new file mode 100644 index 000000000000..a54b99aa14b7 --- /dev/null +++ b/storage/.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/storage/MANIFEST.in b/storage/MANIFEST.in new file mode 100644 index 000000000000..cb3a2b9ef4fa --- /dev/null +++ b/storage/MANIFEST.in @@ -0,0 +1,4 @@ +include README.rst +graft google +graft unit_tests +global-exclude *.pyc diff --git a/storage/README.rst b/storage/README.rst new file mode 100644 index 000000000000..a8bcf0e656b3 --- /dev/null +++ b/storage/README.rst @@ -0,0 +1,64 @@ +Python Client for Google Cloud Storage +====================================== + + Python idiomatic client for `Google Cloud Storage`_ + +.. _Google Cloud Storage: https://cloud.google.com/storage/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-storage + +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 Storage`_ (`Storage API docs`_) allows you to store data on +Google infrastructure with very high reliability, performance and +availability, and can be used to distribute large data objects to users +via direct download. + +.. _Cloud Storage: https://cloud.google.com/storage/docs +.. _Storage API docs: https://cloud.google.com/storage/docs/json_api/v1 + +See the ``google-cloud-python`` API `storage documentation`_ to learn how to +connect to Cloud Storage using this Client Library. + +.. _storage documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/storage-client.html + +You need to create a Google Cloud Storage bucket to use this client library. +Follow along with the `official Google Cloud Storage documentation`_ to learn +how to create a bucket. + +.. _official Google Cloud Storage documentation: https://cloud.google.com/storage/docs/cloud-console#_creatingbuckets + +.. code:: python + + from google.cloud import storage + client = storage.Client() + bucket = client.get_bucket('bucket-id-here') + # Then do other things... + blob = bucket.get_blob('remote/path/to/file.txt') + print(blob.download_as_string()) + blob.upload_from_string('New contents!') + blob2 = bucket.blob('remote/path/storage.txt') + blob2.upload_from_filename(filename='/local/path.txt') diff --git a/storage/setup.py b/storage/setup.py new file mode 100644 index 000000000000..fb6cb3cb3ca9 --- /dev/null +++ b/storage/setup.py @@ -0,0 +1,68 @@ +# 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', +] + +setup( + name='google-cloud-storage', + version='0.20.0dev', + description='Python Client for Google Cloud Storage', + long_description=README, + namespace_packages=[ + 'google', + 'google.cloud', + ], + packages=find_packages(), + install_requires=REQUIREMENTS, + **SETUP_BASE +) diff --git a/storage/tox.ini b/storage/tox.ini new file mode 100644 index 000000000000..c6df74529bed --- /dev/null +++ b/storage/tox.ini @@ -0,0 +1,30 @@ +[tox] +envlist = + py27,py34,py35,cover + +[testing] +deps = + {toxinidir}/../core + pytest +covercmd = + py.test --quiet \ + --cov=google.cloud.storage \ + --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/tox.ini b/tox.ini index a32273c174da..1778dcf258ec 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,7 @@ envlist = deps = {toxinidir}/core {toxinidir}/bigtable + {toxinidir}/storage pytest covercmd = py.test --quiet \ @@ -25,6 +26,12 @@ covercmd = --cov-append \ --cov-config {toxinidir}/.coveragerc \ bigtable/unit_tests + py.test --quiet \ + --cov=google.cloud \ + --cov=unit_tests \ + --cov-append \ + --cov-config {toxinidir}/.coveragerc \ + storage/unit_tests coverage report --show-missing --fail-under=100 [testenv]