Skip to content

Commit bd82827

Browse files
partheagcf-owl-bot[bot]
andauthoredDec 1, 2023
feat: Introduce compatibility with native namespace packages (#561)
* feat: Introduce compatibility with native namespace packages * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 40c8ae0 commit bd82827

File tree

3 files changed

+31
-33
lines changed

3 files changed

+31
-33
lines changed
 

‎google/__init__.py

-25
This file was deleted.

‎setup.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,11 @@
6363
# Only include packages under the 'google' namespace. Do not include tests,
6464
# benchmarks, etc.
6565
packages = [
66-
package for package in setuptools.find_packages() if package.startswith("google")
66+
package
67+
for package in setuptools.find_namespace_packages()
68+
if package.startswith("google")
6769
]
6870

69-
# Determine which namespaces are needed.
70-
namespaces = ["google"]
71-
if "google.cloud" in packages:
72-
namespaces.append("google.cloud")
73-
74-
7571
setuptools.setup(
7672
name=name,
7773
version=version,
@@ -97,7 +93,6 @@
9793
],
9894
platforms="Posix; MacOS X; Windows",
9995
packages=packages,
100-
namespace_packages=namespaces,
10196
install_requires=dependencies,
10297
extras_require=extras,
10398
python_requires=">=3.7",

‎tests/unit/test_packaging.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
# The ``google`` namespace package should not be masked
22+
# by the presence of ``google-api-core``.
23+
google = tmp_path / "google"
24+
google.mkdir()
25+
google.joinpath("othermod.py").write_text("")
26+
env = dict(os.environ, PYTHONPATH=str(tmp_path))
27+
cmd = [sys.executable, "-m", "google.othermod"]
28+
subprocess.check_call(cmd, env=env)

0 commit comments

Comments
 (0)
Please sign in to comment.