Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 10ad75d

Browse filesBrowse files
gkevinzhenggcf-owl-bot[bot]parthea
authored
feat: use native namespaces instead of pkg_resources (#812)
* feat: use native namespaces instead of pkg_resources * linting * Added packaging test for native namespace support. * 🦉 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> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent d73cc56 commit 10ad75d
Copy full SHA for 10ad75d

File tree

Expand file treeCollapse file tree

4 files changed

+57
-50
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+57
-50
lines changed

‎google/__init__.py

Copy file name to clipboardExpand all lines: google/__init__.py
-22Lines changed: 0 additions & 22 deletions
This file was deleted.

‎google/cloud/__init__.py

Copy file name to clipboardExpand all lines: google/cloud/__init__.py
-22Lines changed: 0 additions & 22 deletions
This file was deleted.

‎setup.py

Copy file name to clipboardExpand all lines: setup.py
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,10 @@
5555

5656
packages = [
5757
package
58-
for package in setuptools.PEP420PackageFinder.find()
58+
for package in setuptools.find_namespace_packages()
5959
if package.startswith("google")
6060
]
6161

62-
namespaces = ["google"]
63-
if "google.cloud" in packages:
64-
namespaces.append("google.cloud")
65-
6662
setuptools.setup(
6763
name=name,
6864
version=version,
@@ -89,7 +85,6 @@
8985
platforms="Posix; MacOS X; Windows",
9086
packages=packages,
9187
python_requires=">=3.7",
92-
namespace_packages=namespaces,
9388
install_requires=dependencies,
9489
include_package_data=True,
9590
zip_safe=False,

‎tests/unit/test_packaging.py

Copy file name to clipboard
+56Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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-logging``.
23+
24+
google = tmp_path / "google"
25+
google.mkdir()
26+
google.joinpath("othermod.py").write_text("")
27+
28+
google_otherpkg = tmp_path / "google" / "otherpkg"
29+
google_otherpkg.mkdir()
30+
google_otherpkg.joinpath("__init__.py").write_text("")
31+
32+
# The ``google.cloud`` namespace package should not be masked
33+
# by the presence of ``google-cloud-logging``.
34+
google_cloud = tmp_path / "google" / "cloud"
35+
google_cloud.mkdir()
36+
google_cloud.joinpath("othermod.py").write_text("")
37+
38+
google_cloud_otherpkg = tmp_path / "google" / "cloud" / "otherpkg"
39+
google_cloud_otherpkg.mkdir()
40+
google_cloud_otherpkg.joinpath("__init__.py").write_text("")
41+
42+
env = dict(os.environ, PYTHONPATH=str(tmp_path))
43+
44+
for pkg in [
45+
"google.othermod",
46+
"google.cloud.othermod",
47+
"google.otherpkg",
48+
"google.cloud.otherpkg",
49+
"google.cloud.logging",
50+
]:
51+
cmd = [sys.executable, "-c", f"import {pkg}"]
52+
subprocess.check_output(cmd, env=env)
53+
54+
for module in ["google.othermod", "google.cloud.othermod"]:
55+
cmd = [sys.executable, "-m", module]
56+
subprocess.check_output(cmd, env=env)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.