Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce compatibility with native namespace packages #1205

Merged
merged 13 commits into from
Jun 26, 2023
Merged
9 changes: 2 additions & 7 deletions google/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@

"""Google namespace package."""

try:
import pkg_resources
import pkgutil

pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil

__path__ = pkgutil.extend_path(__path__, __name__) # type: ignore
__path__ = pkgutil.extend_path(__path__, __name__) # type: ignore
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
long_description=long_description,
url="https://github.com/googleapis/google-auth-library-python",
packages=find_packages(exclude=("tests*", "system_tests*")),
namespace_packages=("google",),
install_requires=DEPENDENCIES,
extras_require=extras,
python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*",
Expand Down
30 changes: 30 additions & 0 deletions tests/test_packaging.py
Original file line number Diff line number Diff line change
@@ -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):
clundin25 marked this conversation as resolved.
Show resolved Hide resolved
"""
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)