diff --git a/google/__init__.py b/google/__init__.py deleted file mode 100644 index 70a7bd995..000000000 --- a/google/__init__.py +++ /dev/null @@ -1,24 +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. - -"""Google namespace package.""" - -try: - import pkg_resources - - pkg_resources.declare_namespace(__name__) -except ImportError: - import pkgutil - - __path__ = pkgutil.extend_path(__path__, __name__) # type: ignore diff --git a/noxfile.py b/noxfile.py index 19e162bcc..b9d183385 100644 --- a/noxfile.py +++ b/noxfile.py @@ -82,7 +82,7 @@ def mypy(session): "types-six", "types-mock", ) - session.run("mypy", "google/", "tests/", "tests_async/") + session.run("mypy", "-p", "google", "-p", "tests", "-p", "tests_async") @nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]) diff --git a/setup.py b/setup.py index 01cf80806..4a91925dd 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ import io import os -from setuptools import find_packages +from setuptools import find_namespace_packages from setuptools import setup @@ -58,8 +58,9 @@ description="Google Authentication Library", long_description=long_description, url="https://github.com/googleapis/google-auth-library-python", - packages=find_packages(exclude=("tests*", "system_tests*")), - namespace_packages=("google",), + packages=find_namespace_packages( + exclude=("tests*", "system_tests*", "docs*", "samples*") + ), install_requires=DEPENDENCIES, extras_require=extras, python_requires=">=3.6", diff --git a/tests/test_packaging.py b/tests/test_packaging.py new file mode 100644 index 000000000..e87b3a21b --- /dev/null +++ b/tests/test_packaging.py @@ -0,0 +1,30 @@ +# Copyright 2022 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 ``google-auth``. + """ + 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)