Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 713e388

Browse files
partheagcf-owl-bot[bot]vchudnov-g
authored
fix: migrate to native namespace packages (#187)
* fix: drop pkg_resources * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix test to cater for new location for google-cloud-speech * typo * fix noxfile: install with -e * add test for google.logging --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Victor Chudnovsky <[email protected]>
1 parent 4643f9c commit 713e388

File tree

10 files changed

+54
-56
lines changed

10 files changed

+54
-56
lines changed

google/api/__init__.py

Whitespace-only changes.

google/gapic/metadata/__init__.py

Whitespace-only changes.

google/logging/__init__.py

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

google/logging/type/__init__.py

Whitespace-only changes.

google/longrunning/__init__.py

Whitespace-only changes.

google/rpc/__init__.py

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

google/rpc/context/__init__.py

Whitespace-only changes.

google/type/__init__.py

Whitespace-only changes.

setup.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import os
1717

1818
import setuptools
19+
from setuptools import find_namespace_packages
1920

2021

2122
name = "googleapis-common-protos"
@@ -36,12 +37,6 @@
3637
with io.open(readme_filename, encoding="utf-8") as readme_file:
3738
readme = readme_file.read()
3839

39-
packages = [
40-
package
41-
for package in setuptools.PEP420PackageFinder.find()
42-
if package.startswith("google")
43-
]
44-
4540
setuptools.setup(
4641
name=name,
4742
version=version,
@@ -66,10 +61,9 @@
6661
install_requires=dependencies,
6762
extras_require=extras_require,
6863
license="Apache-2.0",
69-
packages=packages,
7064
package_data={"": ["*.proto"]},
7165
python_requires=">=3.7",
72-
namespace_packages=["google", "google.logging"],
66+
packages=find_namespace_packages(exclude=("tests*", "testing*")),
7367
url="https://github.com/googleapis/python-api-common-protos",
7468
include_package_data=True,
7569
)

tests/unit/test_packaging.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2023 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 ``googleapis-common-protos``.
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)
31+
32+
"""
33+
The ``google.cloud`` namespace package should not be masked
34+
by the presence of ``googleapis-common-protos``.
35+
"""
36+
google_cloud = tmp_path / "google/cloud"
37+
google_cloud.mkdir()
38+
google_cloud.joinpath("othermod.py").write_text("")
39+
env = dict(os.environ, PYTHONPATH=str(tmp_path))
40+
cmd = [sys.executable, "-m", "google.cloud.othermod"]
41+
subprocess.check_call(cmd, env=env)
42+
43+
"""
44+
The ``google.logging`` namespace package should not be masked
45+
by the presence of ``googleapis-common-protos``.
46+
"""
47+
google_logging = tmp_path / "google/logging"
48+
google_logging.mkdir()
49+
google_logging.joinpath("othermod.py").write_text("")
50+
env = dict(os.environ, PYTHONPATH=str(tmp_path))
51+
cmd = [sys.executable, "-m", "google.logging.othermod"]
52+
subprocess.check_call(cmd, env=env)

0 commit comments

Comments
 (0)