From 4fee7a0943fb4a6b4253d610c3aad1c5d0ba5dae Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 8 Nov 2023 16:40:06 +0000 Subject: [PATCH 1/6] fix: drop pkg_resources --- google/api/__init__.py | 0 google/gapic/metadata/__init__.py | 0 google/logging/__init__.py | 24 ------------------ google/logging/type/__init__.py | 0 google/longrunning/__init__.py | 0 google/rpc/__init__.py | 24 ------------------ google/rpc/context/__init__.py | 0 google/type/__init__.py | 0 setup.py | 12 +++------ tests/unit/test_packaging.py | 41 +++++++++++++++++++++++++++++++ 10 files changed, 45 insertions(+), 56 deletions(-) delete mode 100644 google/api/__init__.py delete mode 100644 google/gapic/metadata/__init__.py delete mode 100644 google/logging/__init__.py delete mode 100644 google/logging/type/__init__.py delete mode 100644 google/longrunning/__init__.py delete mode 100644 google/rpc/__init__.py delete mode 100644 google/rpc/context/__init__.py delete mode 100644 google/type/__init__.py create mode 100644 tests/unit/test_packaging.py diff --git a/google/api/__init__.py b/google/api/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/google/gapic/metadata/__init__.py b/google/gapic/metadata/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/google/logging/__init__.py b/google/logging/__init__.py deleted file mode 100644 index 9a1b64a..0000000 --- a/google/logging/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 Google LLC -# -# 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 -# -# https://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/logging/type/__init__.py b/google/logging/type/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/google/longrunning/__init__.py b/google/longrunning/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/google/rpc/__init__.py b/google/rpc/__init__.py deleted file mode 100644 index 9a1b64a..0000000 --- a/google/rpc/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 Google LLC -# -# 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 -# -# https://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/rpc/context/__init__.py b/google/rpc/context/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/google/type/__init__.py b/google/type/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/setup.py b/setup.py index 73599a1..9d483e4 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,7 @@ import os import setuptools +from setuptools import find_namespace_packages name = "googleapis-common-protos" @@ -34,12 +35,6 @@ with io.open(readme_filename, encoding="utf-8") as readme_file: readme = readme_file.read() -packages = [ - package - for package in setuptools.PEP420PackageFinder.find() - if package.startswith("google") -] - setuptools.setup( name=name, version=version, @@ -64,10 +59,11 @@ install_requires=dependencies, extras_require=extras_require, license="Apache-2.0", - packages=packages, package_data={"": ["*.proto"]}, python_requires=">=3.7", - namespace_packages=["google", "google.logging"], + packages=find_namespace_packages( + exclude=("tests*", "testing*") + ), url="https://github.com/googleapis/python-api-common-protos", include_package_data=True, ) diff --git a/tests/unit/test_packaging.py b/tests/unit/test_packaging.py new file mode 100644 index 0000000..695a096 --- /dev/null +++ b/tests/unit/test_packaging.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC +# +# 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 +import subprocess +import sys + + +def test_namespace_package_compat(tmp_path): + """ + The ``google`` namespace package should not be masked + by the presence of ``googleapis-common-protos``. + """ + google = tmp_path / "google" + google.mkdir() + google.joinpath("othermod.py").write_text("") + env = dict(os.environ, PYTHONPATH=str(tmp_path)) + cmd = [sys.executable, "-m", "google.othermod"] + subprocess.check_call(cmd, env=env) + + """ + The ``google.cloud`` namespace package should not be masked + by the presence of ``googleapis-common-protos``. + """ + google_cloud = tmp_path / "google/cloud" + google_cloud.mkdir() + google_cloud.joinpath("othermod.py").write_text("") + env = dict(os.environ, PYTHONPATH=str(tmp_path)) + cmd = [sys.executable, "-m", "google.cloud.othermod"] + subprocess.check_call(cmd, env=env) From 66a67c3c7dc9b0099485dad086db9ef0cc2edd8e Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 8 Nov 2023 16:57:54 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- setup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 9d483e4..e7f5b02 100644 --- a/setup.py +++ b/setup.py @@ -61,9 +61,7 @@ license="Apache-2.0", package_data={"": ["*.proto"]}, python_requires=">=3.7", - packages=find_namespace_packages( - exclude=("tests*", "testing*") - ), + packages=find_namespace_packages(exclude=("tests*", "testing*")), url="https://github.com/googleapis/python-api-common-protos", include_package_data=True, ) From b4f30f01609f9610b7a8dd25629d89fa33ffad9b Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 8 Nov 2023 19:40:10 +0000 Subject: [PATCH 3/6] fix test to cater for new location for google-cloud-speech --- noxfile.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/noxfile.py b/noxfile.py index 0dd9d4b..72487d7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -125,7 +125,10 @@ def system(session): @nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"]) @nox.parametrize( "library", - ["python-pubsub", "python-speech"], + [ + ("python-pubsub", None) + ("google-cloud-python", "google-cloud-speech"), + ], ids=["pubsub", "speech"], ) def test(session, library): @@ -141,24 +144,26 @@ def test(session, library): * Text-to-Speech: Full GAPIC. * Speech: Full GAPIC, has long running operations. """ + repository, package = library try: - session.run("git", "-C", library, "pull", external=True) + session.run("git", "-C", repository, "pull", external=True) except nox.command.CommandFailed: session.run( "git", "clone", "--single-branch", - f"https://github.com/googleapis/{library}", + f"https://github.com/googleapis/{repository}", external=True, ) - session.cd(library) - + session.cd(repository) + if package: + session.cd(f'packages/{package}') unit(session) # system tests are run on 3.7 only if session.python == "3.7": - if library == "python-pubsub": + if repository == "python-pubsub": session.install("psutil") session.install("flaky") system(session) From 1cbe6c3174243f8573d5a0a16b3100384290d562 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 8 Nov 2023 19:44:08 +0000 Subject: [PATCH 4/6] typo --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 72487d7..e5ddf77 100644 --- a/noxfile.py +++ b/noxfile.py @@ -126,7 +126,7 @@ def system(session): @nox.parametrize( "library", [ - ("python-pubsub", None) + ("python-pubsub", None), ("google-cloud-python", "google-cloud-speech"), ], ids=["pubsub", "speech"], From edcece94149400ae2d17343f5558de3e207c109e Mon Sep 17 00:00:00 2001 From: Victor Chudnovsky Date: Thu, 9 Nov 2023 15:06:30 -0800 Subject: [PATCH 5/6] fix noxfile: install with -e --- noxfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index e5ddf77..a1a03a3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -61,7 +61,7 @@ def default(session): # Install googleapis-api-common-protos # This *must* be the last install command to get the package from source. - session.install("e", "..", "-c", constraints_path) + session.install("-e", "..", "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -113,7 +113,7 @@ def system(session): # Install googleapis-api-common-protos # This *must* be the last install command to get the package from source. - session.install("e", "..", "-c", constraints_path) + session.install("-e", "..", "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: From ad77d38764412e3e9b1649b5e550e548a13db3e0 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 28 Nov 2023 16:14:07 +0000 Subject: [PATCH 6/6] add test for google.logging --- tests/unit/test_packaging.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unit/test_packaging.py b/tests/unit/test_packaging.py index 695a096..f1ab3ff 100644 --- a/tests/unit/test_packaging.py +++ b/tests/unit/test_packaging.py @@ -39,3 +39,14 @@ def test_namespace_package_compat(tmp_path): env = dict(os.environ, PYTHONPATH=str(tmp_path)) cmd = [sys.executable, "-m", "google.cloud.othermod"] subprocess.check_call(cmd, env=env) + + """ + The ``google.logging`` namespace package should not be masked + by the presence of ``googleapis-common-protos``. + """ + google_logging = tmp_path / "google/logging" + google_logging.mkdir() + google_logging.joinpath("othermod.py").write_text("") + env = dict(os.environ, PYTHONPATH=str(tmp_path)) + cmd = [sys.executable, "-m", "google.logging.othermod"] + subprocess.check_call(cmd, env=env)