From 2ed915ec4b35df6fad04f42df25e48667148fcf5 Mon Sep 17 00:00:00 2001 From: Andrew Gorcester Date: Thu, 9 Nov 2023 02:10:16 -0800 Subject: [PATCH] fix: use native namespace to avoid pkg_resources warnings (#1176) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: use native namespace to avoid pkg_resources warnings * remove comment header of empty files * bring in line with auth library changes * lint * fix coverage * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * add tests and remove namespace_packages in setup.py * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * mark this as a system test * remove test for now * remove obsolete namespace list --------- Co-authored-by: Owl Bot --- .coveragerc | 2 ++ google/__init__.py | 22 ---------------------- google/cloud/__init__.py | 22 ---------------------- owlbot.py | 6 ++++++ setup.py | 10 +++------- 5 files changed, 11 insertions(+), 51 deletions(-) delete mode 100644 google/__init__.py delete mode 100644 google/cloud/__init__.py diff --git a/.coveragerc b/.coveragerc index c540edf34..21a2eaca4 100644 --- a/.coveragerc +++ b/.coveragerc @@ -18,6 +18,7 @@ [run] branch = True omit = + .nox/* google/__init__.py google/cloud/__init__.py @@ -32,6 +33,7 @@ exclude_lines = # Ignore abstract methods raise NotImplementedError omit = + .nox/* */gapic/*.py */proto/*.py */core/*.py diff --git a/google/__init__.py b/google/__init__.py deleted file mode 100644 index 0e1bc5131..000000000 --- a/google/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2016 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. - -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 0e1bc5131..000000000 --- a/google/cloud/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2016 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. - -try: - import pkg_resources - - pkg_resources.declare_namespace(__name__) -except ImportError: - import pkgutil - - __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/owlbot.py b/owlbot.py index 50a787f34..0333b1d48 100644 --- a/owlbot.py +++ b/owlbot.py @@ -67,6 +67,12 @@ export DUAL_REGION_LOC_1 export DUAL_REGION_LOC_2""") +s.replace( + ".coveragerc", + "omit =", + """omit = + .nox/*""") + python.py_samples(skip_readmes=True) s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/setup.py b/setup.py index 88d2f581b..67958419f 100644 --- a/setup.py +++ b/setup.py @@ -54,14 +54,11 @@ # Only include packages under the 'google' namespace. Do not include tests, # benchmarks, etc. packages = [ - package for package in setuptools.find_packages() if package.startswith("google") + package + for package in setuptools.find_namespace_packages() + if package.startswith("google") ] -# Determine which namespaces are needed. -namespaces = ["google"] -if "google.cloud" in packages: - namespaces.append("google.cloud") - setuptools.setup( name=name, @@ -88,7 +85,6 @@ ], platforms="Posix; MacOS X; Windows", packages=packages, - namespace_packages=namespaces, install_requires=dependencies, extras_require=extras, python_requires=">=3.7",