Skip to content

Commit

Permalink
feat: Introduce compatibility with native namespace packages (#1205)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco authored Jun 26, 2023
1 parent 6df6a72 commit 2f75922
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 28 deletions.
24 changes: 0 additions & 24 deletions google/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import io
import os

from setuptools import find_packages
from setuptools import find_namespace_packages
from setuptools import setup


Expand Down Expand Up @@ -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",
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):
"""
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)

0 comments on commit 2f75922

Please sign in to comment.