From 8d15eea852e13af3b37edad95bdb7716240c5afd Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 26 Sep 2016 17:00:12 -0700 Subject: [PATCH 1/5] Moving all speech files into subdirectory. Done via: $ mkdir -p speech/google/cloud $ cp google/__init__.py speech/google/__init__.py $ git add speech/google/__init__.py $ cp google/cloud/__init__.py speech/google/cloud/__init__.py $ git add speech/google/cloud/__init__.py $ git mv google/cloud/speech speech/google/cloud/speech $ git mv unit_tests/speech speech/unit_tests --- speech/google/__init__.py | 20 +++++++++++++++++++ speech/google/cloud/__init__.py | 20 +++++++++++++++++++ .../google}/cloud/speech/__init__.py | 0 .../google}/cloud/speech/client.py | 0 .../google}/cloud/speech/connection.py | 0 .../speech => speech/unit_tests}/__init__.py | 0 .../speech => speech/unit_tests}/_fixtures.py | 0 .../unit_tests}/test_client.py | 0 .../unit_tests}/test_connection.py | 0 9 files changed, 40 insertions(+) create mode 100644 speech/google/__init__.py create mode 100644 speech/google/cloud/__init__.py rename {google => speech/google}/cloud/speech/__init__.py (100%) rename {google => speech/google}/cloud/speech/client.py (100%) rename {google => speech/google}/cloud/speech/connection.py (100%) rename {unit_tests/speech => speech/unit_tests}/__init__.py (100%) rename {unit_tests/speech => speech/unit_tests}/_fixtures.py (100%) rename {unit_tests/speech => speech/unit_tests}/test_client.py (100%) rename {unit_tests/speech => speech/unit_tests}/test_connection.py (100%) diff --git a/speech/google/__init__.py b/speech/google/__init__.py new file mode 100644 index 000000000000..b2b833373882 --- /dev/null +++ b/speech/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/speech/google/cloud/__init__.py b/speech/google/cloud/__init__.py new file mode 100644 index 000000000000..8ac7b74af136 --- /dev/null +++ b/speech/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/speech/__init__.py b/speech/google/cloud/speech/__init__.py similarity index 100% rename from google/cloud/speech/__init__.py rename to speech/google/cloud/speech/__init__.py diff --git a/google/cloud/speech/client.py b/speech/google/cloud/speech/client.py similarity index 100% rename from google/cloud/speech/client.py rename to speech/google/cloud/speech/client.py diff --git a/google/cloud/speech/connection.py b/speech/google/cloud/speech/connection.py similarity index 100% rename from google/cloud/speech/connection.py rename to speech/google/cloud/speech/connection.py diff --git a/unit_tests/speech/__init__.py b/speech/unit_tests/__init__.py similarity index 100% rename from unit_tests/speech/__init__.py rename to speech/unit_tests/__init__.py diff --git a/unit_tests/speech/_fixtures.py b/speech/unit_tests/_fixtures.py similarity index 100% rename from unit_tests/speech/_fixtures.py rename to speech/unit_tests/_fixtures.py diff --git a/unit_tests/speech/test_client.py b/speech/unit_tests/test_client.py similarity index 100% rename from unit_tests/speech/test_client.py rename to speech/unit_tests/test_client.py diff --git a/unit_tests/speech/test_connection.py b/speech/unit_tests/test_connection.py similarity index 100% rename from unit_tests/speech/test_connection.py rename to speech/unit_tests/test_connection.py From 82b20faa96106c4f289991ec3ddd451f5631edd6 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 26 Sep 2016 17:00:12 -0700 Subject: [PATCH 2/5] Making speech subpackage into a proper package. - Adding README, setup.py, MANIFEST.in, .coveragerc and tox.ini - Adding google-cloud-speech as a dependency to the umbrella package - Adding the speech subdirectory into the list of packages for verifying the docs - Incorporating the speech subdirectory into the umbrella coverage report - Adding the speech only tox tests to the Travis config - Adding {toxinidir}/../core as a dependency for the speech tox config --- .travis.yml | 3 ++ scripts/verify_included_modules.py | 1 + setup.py | 1 + speech/.coveragerc | 11 +++++ speech/MANIFEST.in | 4 ++ speech/README.rst | 44 +++++++++++++++++++ speech/setup.py | 68 ++++++++++++++++++++++++++++++ speech/tox.ini | 30 +++++++++++++ tox.ini | 7 +++ 9 files changed, 169 insertions(+) create mode 100644 speech/.coveragerc create mode 100644 speech/MANIFEST.in create mode 100644 speech/README.rst create mode 100644 speech/setup.py create mode 100644 speech/tox.ini diff --git a/.travis.yml b/.travis.yml index 1ea74f1cb664..8a37a59a6bda 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ script: - (cd monitoring && tox -e py27) - (cd vision && tox -e py27) - (cd translate && tox -e py27) + - (cd speech && tox -e py27) - tox -e py34 - (cd core && tox -e py34) - (cd bigtable && tox -e py34) @@ -35,6 +36,7 @@ script: - (cd monitoring && tox -e py34) - (cd vision && tox -e py34) - (cd translate && tox -e py34) + - (cd speech && tox -e py34) - tox -e lint - tox -e cover - (cd core && tox -e cover) @@ -51,6 +53,7 @@ script: - (cd monitoring && tox -e cover) - (cd vision && tox -e cover) - (cd translate && tox -e cover) + - (cd speech && 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 d76c44d5e009..d18f146d6203 100644 --- a/scripts/verify_included_modules.py +++ b/scripts/verify_included_modules.py @@ -70,6 +70,7 @@ 'monitoring', 'pubsub', 'resource_manager', + 'speech', 'storage', 'translate', 'vision', diff --git a/setup.py b/setup.py index a322be4627b7..3208b83cadb2 100644 --- a/setup.py +++ b/setup.py @@ -61,6 +61,7 @@ 'google-cloud-monitoring', 'google-cloud-pubsub', 'google-cloud-resource-manager', + 'google-cloud-speech', 'google-cloud-storage', 'google-cloud-translate', 'google-cloud-vision', diff --git a/speech/.coveragerc b/speech/.coveragerc new file mode 100644 index 000000000000..a54b99aa14b7 --- /dev/null +++ b/speech/.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/speech/MANIFEST.in b/speech/MANIFEST.in new file mode 100644 index 000000000000..cb3a2b9ef4fa --- /dev/null +++ b/speech/MANIFEST.in @@ -0,0 +1,4 @@ +include README.rst +graft google +graft unit_tests +global-exclude *.pyc diff --git a/speech/README.rst b/speech/README.rst new file mode 100644 index 000000000000..8a1dad623e3a --- /dev/null +++ b/speech/README.rst @@ -0,0 +1,44 @@ +Python Client for Google Cloud Speech +===================================== + + Python idiomatic client for `Google Cloud Speech`_ + +.. _Google Cloud Speech: https://cloud.google.com/speech/ + +- `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-speech + +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 +------------- + +`Cloud Speech API`_ enables easy integration of Google speech +recognition technologies into developer applications. Send audio +and receive a text transcription from the Cloud Speech API service. + +.. _Cloud Speech API: https://cloud.google.com/speech/ + +See the ``google-cloud-python`` API `speech documentation`_ to learn how to +connect to the Google Cloud Speech API using this Client Library. + +.. _speech documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/speech-usage.html diff --git a/speech/setup.py b/speech/setup.py new file mode 100644 index 000000000000..de70baf6b1e4 --- /dev/null +++ b/speech/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-speech', + version='0.20.0dev', + description='Python Client for Google Cloud Speech', + long_description=README, + namespace_packages=[ + 'google', + 'google.cloud', + ], + packages=find_packages(), + install_requires=REQUIREMENTS, + **SETUP_BASE +) diff --git a/speech/tox.ini b/speech/tox.ini new file mode 100644 index 000000000000..8aec90a4b2f9 --- /dev/null +++ b/speech/tox.ini @@ -0,0 +1,30 @@ +[tox] +envlist = + py27,py34,py35,cover + +[testing] +deps = + {toxinidir}/../core + pytest +covercmd = + py.test --quiet \ + --cov=google.cloud.speech \ + --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 4ac4c37bddb3..3d6fda19fe94 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,7 @@ deps = {toxinidir}/monitoring {toxinidir}/vision {toxinidir}/translate + {toxinidir}/speech pytest covercmd = py.test --quiet \ @@ -109,6 +110,12 @@ covercmd = --cov-append \ --cov-config {toxinidir}/.coveragerc \ translate/unit_tests + py.test --quiet \ + --cov=google.cloud \ + --cov=unit_tests \ + --cov-append \ + --cov-config {toxinidir}/.coveragerc \ + speech/unit_tests coverage report --show-missing --fail-under=100 [testenv] From 471079f6963c45fb099874fced6fd19afa7c2e6a Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 26 Sep 2016 17:00:36 -0700 Subject: [PATCH 3/5] Fixing up speech fixture imports. Done via: $ git grep -l 'unit_tests.speech._fixtures' | > xargs sed -i s/'unit_tests.speech._fixtures'/'unit_tests._fixtures'/g --- speech/unit_tests/test_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/speech/unit_tests/test_client.py b/speech/unit_tests/test_client.py index d54eeedea586..53e1eb67b89e 100644 --- a/speech/unit_tests/test_client.py +++ b/speech/unit_tests/test_client.py @@ -41,7 +41,7 @@ def test_sync_recognize_content_with_optional_parameters(self): import base64 from google.cloud._helpers import _to_bytes from google.cloud.speech.client import Encoding - from unit_tests.speech._fixtures import SYNC_RECOGNIZE_RESPONSE + from unit_tests._fixtures import SYNC_RECOGNIZE_RESPONSE _AUDIO_CONTENT = _to_bytes('/9j/4QNURXhpZgAASUkq') _B64_AUDIO_CONTENT = base64.b64encode(_AUDIO_CONTENT) @@ -89,7 +89,7 @@ def test_sync_recognize_content_with_optional_parameters(self): def test_sync_recognize_source_uri_without_optional_parameters(self): from google.cloud.speech.client import Encoding - from unit_tests.speech._fixtures import SYNC_RECOGNIZE_RESPONSE + from unit_tests._fixtures import SYNC_RECOGNIZE_RESPONSE RETURNED = SYNC_RECOGNIZE_RESPONSE REQUEST = { @@ -162,7 +162,7 @@ def test_sync_recognize_without_samplerate(self): def test_sync_recognize_with_empty_results(self): from google.cloud.speech.client import Encoding - from unit_tests.speech._fixtures import SYNC_RECOGNIZE_EMPTY_RESPONSE + from unit_tests._fixtures import SYNC_RECOGNIZE_EMPTY_RESPONSE credentials = _Credentials() client = self._makeOne(credentials=credentials) From 9c00d52e37ceeabf6e56b5d0d859a0e7a17f8c46 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 26 Sep 2016 17:01:40 -0700 Subject: [PATCH 4/5] Manually removing speech from umbrella package. This is because the implementation is not complete. --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 3208b83cadb2..a322be4627b7 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,6 @@ 'google-cloud-monitoring', 'google-cloud-pubsub', 'google-cloud-resource-manager', - 'google-cloud-speech', 'google-cloud-storage', 'google-cloud-translate', 'google-cloud-vision', From 07c1047ee3bf1f12060f7fe150f6db3791cd4ffd Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 26 Sep 2016 17:24:04 -0700 Subject: [PATCH 5/5] Removing unused directories for umbrella package. Also updating tox and Travis configs to ignore the `py${VERSION}` tests for the umbrella package and changing the umbrella `cover` command to no longer refer to the now removed base `unit_tests` directory. --- .travis.yml | 2 -- google/__init__.py | 20 -------------------- google/cloud/__init__.py | 20 -------------------- setup.py | 5 ----- tox.ini | 8 +------- unit_tests/__init__.py | 13 ------------- unit_tests/streaming/__init__.py | 13 ------------- 7 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 google/__init__.py delete mode 100644 google/cloud/__init__.py delete mode 100644 unit_tests/__init__.py delete mode 100644 unit_tests/streaming/__init__.py diff --git a/.travis.yml b/.travis.yml index 8a37a59a6bda..0f496d7f19ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ install: - pip install --upgrade pip tox script: - - tox -e py27 - (cd core && tox -e py27) - (cd bigtable && tox -e py27) - (cd storage && tox -e py27) @@ -21,7 +20,6 @@ script: - (cd vision && tox -e py27) - (cd translate && tox -e py27) - (cd speech && tox -e py27) - - tox -e py34 - (cd core && tox -e py34) - (cd bigtable && tox -e py34) - (cd storage && tox -e py34) diff --git a/google/__init__.py b/google/__init__.py deleted file mode 100644 index b2b833373882..000000000000 --- a/google/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# 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/google/cloud/__init__.py b/google/cloud/__init__.py deleted file mode 100644 index 8ac7b74af136..000000000000 --- a/google/cloud/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# 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/setup.py b/setup.py index a322be4627b7..359a4a5f76eb 100644 --- a/setup.py +++ b/setup.py @@ -71,11 +71,6 @@ version='0.20.0dev', description='API Client library for Google Cloud', long_description=README, - namespace_packages=[ - 'google', - 'google.cloud', - ], - packages=find_packages(), install_requires=REQUIREMENTS, **SETUP_BASE ) diff --git a/tox.ini b/tox.ini index 3d6fda19fe94..f55f675c7105 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py27,py34,py35,cover,docs,lint + cover,docs,lint [testing] deps = @@ -25,12 +25,6 @@ covercmd = --cov=google.cloud \ --cov=unit_tests \ --cov-config {toxinidir}/.coveragerc \ - unit_tests - py.test --quiet \ - --cov=google.cloud \ - --cov=unit_tests \ - --cov-append \ - --cov-config {toxinidir}/.coveragerc \ core/unit_tests py.test --quiet \ --cov=google.cloud \ diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py deleted file mode 100644 index 58e0d9153632..000000000000 --- a/unit_tests/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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. diff --git a/unit_tests/streaming/__init__.py b/unit_tests/streaming/__init__.py deleted file mode 100644 index 58e0d9153632..000000000000 --- a/unit_tests/streaming/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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.