Skip to content

Commit 272fff6

Browse files
feat: Introduce compatibility with native namespace packages (#187)
* 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 4f00e5e commit 272fff6

File tree

6 files changed

+48
-53
lines changed

6 files changed

+48
-53
lines changed

packages/google-cloud-access-context-manager/google/__init__.py

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

packages/google-cloud-access-context-manager/google/identity/__init__.py

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

packages/google-cloud-access-context-manager/google/identity/accesscontextmanager/__init__.py

Whitespace-only changes.

packages/google-cloud-access-context-manager/setup.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545
package for package in setuptools.find_packages() if package.startswith("google")
4646
]
4747

48-
# Determine which namespaces are needed.
49-
namespaces = ["google"]
50-
namespaces.append("google.identity")
51-
5248
setuptools.setup(
5349
name=name,
5450
version=version,
@@ -75,7 +71,6 @@
7571
],
7672
platforms="Posix; MacOS X; Windows",
7773
packages=packages,
78-
namespace_packages=namespaces,
7974
install_requires=dependencies,
8075
python_requires=">=3.7",
8176
include_package_data=True,

packages/google-cloud-access-context-manager/tests/.gitkeep

Whitespace-only changes.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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-cloud-access-context-manager``.
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)
29+
30+
# The ``google.identity`` namespace package should not be masked
31+
# by the presence of ``google-cloud-access-context-manager``.
32+
google_identity = tmp_path / "google" / "identity"
33+
google_identity.mkdir()
34+
google_identity.joinpath("othermod.py").write_text("")
35+
env = dict(os.environ, PYTHONPATH=str(tmp_path))
36+
cmd = [sys.executable, "-m", "google.identity.othermod"]
37+
subprocess.check_call(cmd, env=env)
38+
39+
# The ``google.identity.accesscontextmanager`` namespace package should not be masked
40+
# by the presence of ``google-cloud-access-context-manager``.
41+
google_identity_accesscontextmanager = (
42+
tmp_path / "google" / "identity" / "accesscontextmanager"
43+
)
44+
google_identity_accesscontextmanager.mkdir()
45+
google_identity_accesscontextmanager.joinpath("othermod.py").write_text("")
46+
env = dict(os.environ, PYTHONPATH=str(tmp_path))
47+
cmd = [sys.executable, "-m", "google.identity.accesscontextmanager.othermod"]
48+
subprocess.check_call(cmd, env=env)

0 commit comments

Comments
 (0)