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

Commit 93217c3

Browse files
partheaohmayr
andauthored
feat: Introduce compatibility with native namespace packages (#59)
* feat: Introduce compatibility with native namespace packages * add unit test presubmits * update unit test versions * update required checks --------- Co-authored-by: ohmayr <omairnaveed@ymail.com>
1 parent 6e70bcd commit 93217c3

File tree

14 files changed

+117
-33
lines changed

14 files changed

+117
-33
lines changed

.github/sync-repo-settings.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ branchProtectionRules:
99
requiredStatusCheckContexts:
1010
- 'cla/google'
1111
- 'OwlBot Post Processor'
12+
- 'docs'
13+
- 'docfx'
14+
- 'lint'
15+
- 'unit (3.7)'
16+
- 'unit (3.8)'
17+
- 'unit (3.9)'
18+
- 'unit (3.10)'
19+
- 'unit (3.11)'
20+
- 'cover'
1221
permissionRules:
1322
- team: actools-python
1423
permission: admin

.github/workflows/unittest.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- main
5+
name: unittest
6+
jobs:
7+
unit:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
- name: Setup Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: ${{ matrix.python }}
19+
- name: Install nox
20+
run: |
21+
python -m pip install --upgrade setuptools pip wheel
22+
python -m pip install nox
23+
- name: Run unit tests
24+
env:
25+
COVERAGE_FILE: .coverage-${{ matrix.python }}
26+
run: |
27+
nox -s unit-${{ matrix.python }}
28+
- name: Upload coverage results
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: coverage-artifacts
32+
path: .coverage-${{ matrix.python }}
33+
34+
cover:
35+
runs-on: ubuntu-latest
36+
needs:
37+
- unit
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v3
41+
- name: Setup Python
42+
uses: actions/setup-python@v4
43+
with:
44+
python-version: "3.8"
45+
- name: Install coverage
46+
run: |
47+
python -m pip install --upgrade setuptools pip wheel
48+
python -m pip install coverage
49+
- name: Download coverage results
50+
uses: actions/download-artifact@v3
51+
with:
52+
name: coverage-artifacts
53+
path: .coverage-results/
54+
- name: Report coverage results
55+
run: |
56+
coverage combine .coverage-results/.coverage*
57+
coverage report --show-missing --fail-under=100

google/iam/__init__.py

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

noxfile.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@ def default(session):
5555
session.install("asyncmock", "pytest-asyncio")
5656

5757
session.install("mock", "pytest", "pytest-cov")
58-
session.install("-e", ".")
59-
6058
constraints_path = str(
6159
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
6260
)
6361

6462
# Install grpc-google-iam-v1
6563
# This *must* be the last install command to get the package from source.
66-
session.install("e", "..", "-c", constraints_path)
64+
session.install("-e", ".", "-c", constraints_path)
6765

6866
# Run py.test against the unit tests.
6967
session.run(
@@ -80,6 +78,7 @@ def default(session):
8078
)
8179

8280

81+
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
8382
def unit(session):
8483
"""Run the unit test suite."""
8584
default(session)
@@ -106,15 +105,13 @@ def system(session):
106105
# virtualenv's dist-packages.
107106
session.install("mock", "pytest", "google-cloud-testutils")
108107

109-
session.install("-e", ".")
110-
111108
constraints_path = str(
112109
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
113110
)
114111

115112
# Install grpc-google-iam-v1
116113
# This *must* be the last install command to get the package from source.
117-
session.install("e", "..", "-c", constraints_path)
114+
session.install("-e", ".", "-c", constraints_path)
118115

119116
# Run py.test against the system tests.
120117
if system_test_exists:
@@ -155,7 +152,7 @@ def test(session, library):
155152

156153
session.cd(library)
157154

158-
unit(session)
155+
default(session)
159156

160157
# system tests are run on 3.7 only
161158
if session.python == "3.7":

owlbot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
s.move(templated_files / "CONTRIBUTING.rst")
5959
s.move(templated_files / "*.md")
6060
s.move(templated_files / "renovate.json")
61-
s.move(templated_files / ".github", excludes=["workflows/unittest.yml"])
61+
s.move(templated_files / ".github")
6262
s.move(templated_files / ".trampolinerc")
6363

6464
python.py_samples(skip_readmes=True)

setup.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,10 @@
3939

4040
packages = [
4141
package
42-
for package in setuptools.PEP420PackageFinder.find()
42+
for package in setuptools.find_namespace_packages()
4343
if package.startswith("google")
4444
]
4545

46-
namespaces = ["google"]
47-
if "google.iam" in packages:
48-
namespaces.append("google.iam")
49-
50-
5146
setuptools.setup(
5247
name=name,
5348
version=version,
@@ -74,7 +69,6 @@
7469
platforms="Posix; MacOS X; Windows",
7570
packages=packages,
7671
python_requires=">=3.7",
77-
namespace_packages=namespaces,
7872
install_requires=dependencies,
7973
include_package_data=True,
8074
zip_safe=False,

testing/constraints-3.10.txt

Whitespace-only changes.

testing/constraints-3.11.txt

Whitespace-only changes.

testing/constraints-3.12.txt

Whitespace-only changes.

testing/constraints-3.7.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)