Skip to content

Commit 2f75922

Browse files
authored
feat: Introduce compatibility with native namespace packages (#1205)
1 parent 6df6a72 commit 2f75922

File tree

4 files changed

+35
-28
lines changed

4 files changed

+35
-28
lines changed

google/__init__.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def mypy(session):
8282
"types-six",
8383
"types-mock",
8484
)
85-
session.run("mypy", "google/", "tests/", "tests_async/")
85+
session.run("mypy", "-p", "google", "-p", "tests", "-p", "tests_async")
8686

8787

8888
@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"])

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import io
1616
import os
1717

18-
from setuptools import find_packages
18+
from setuptools import find_namespace_packages
1919
from setuptools import setup
2020

2121

@@ -58,8 +58,9 @@
5858
description="Google Authentication Library",
5959
long_description=long_description,
6060
url="https://github.com/googleapis/google-auth-library-python",
61-
packages=find_packages(exclude=("tests*", "system_tests*")),
62-
namespace_packages=("google",),
61+
packages=find_namespace_packages(
62+
exclude=("tests*", "system_tests*", "docs*", "samples*")
63+
),
6364
install_requires=DEPENDENCIES,
6465
extras_require=extras,
6566
python_requires=">=3.6",

tests/test_packaging.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
import subprocess
17+
import sys
18+
19+
20+
def test_namespace_package_compat(tmp_path):
21+
"""
22+
The ``google`` namespace package should not be masked
23+
by the presence of ``google-auth``.
24+
"""
25+
google = tmp_path / "google"
26+
google.mkdir()
27+
google.joinpath("othermod.py").write_text("")
28+
env = dict(os.environ, PYTHONPATH=str(tmp_path))
29+
cmd = [sys.executable, "-m", "google.othermod"]
30+
subprocess.check_call(cmd, env=env)

0 commit comments

Comments
 (0)