From b9d8468de166487b6b805d25fd803fb9b71e77eb Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 26 Sep 2016 12:35:57 -0700 Subject: [PATCH] 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 --- .coveragerc | 11 +++++++++ MANIFEST.in | 4 ++++ README.rst | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tox.ini | 30 +++++++++++++++++++++++ 5 files changed, 177 insertions(+) create mode 100644 .coveragerc create mode 100644 MANIFEST.in create mode 100644 README.rst create mode 100644 setup.py create mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..a54b99aa1 --- /dev/null +++ b/.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/MANIFEST.in b/MANIFEST.in new file mode 100644 index 000000000..cb3a2b9ef --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include README.rst +graft google +graft unit_tests +global-exclude *.pyc diff --git a/README.rst b/README.rst new file mode 100644 index 000000000..a8bcf0e65 --- /dev/null +++ b/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/setup.py b/setup.py new file mode 100644 index 000000000..fb6cb3cb3 --- /dev/null +++ b/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/tox.ini b/tox.ini new file mode 100644 index 000000000..c6df74529 --- /dev/null +++ b/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