Skip to content

Commit 0100916

Browse files
authored
fix: allow Protobuf 6.x (#1445)
* fix: allow Protobuf 6.x * add prerelease nox session * add python 3.13 * lint * add test dependencies * add test dependencies * fix(deps): require google-crc32c >= 1.1.3 * fix(deps): require requests >= 2.22.0 * add dependencies for system tests * clean up * clean up * clean up * clean up * clean up * fix cover * clean up * Install dependencies needed for system tests * add dependencies for system test * update noxfile config * add credentials * exclude .kokoro/presubmit/prerelease-deps.cfg template * remove obsolete excludes * clean up * clean up * exclude .kokoro/continuous/prerelease-deps.cfg from templates; remove obsolete replacement * migrate prerelease test from presubmit to continuous build
1 parent 05ffb1e commit 0100916

File tree

10 files changed

+135
-40
lines changed

10 files changed

+135
-40
lines changed

.kokoro/continuous/prerelease-deps.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ env_vars: {
55
key: "NOX_SESSION"
66
value: "prerelease_deps"
77
}
8+
9+
# Credentials needed to test universe domain.
10+
env_vars: {
11+
key: "SECRET_MANAGER_KEYS"
12+
value: "client-library-test-universe-domain-credential"
13+
}

.kokoro/presubmit/prerelease-deps.cfg

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

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In order to add a feature:
2222
documentation.
2323

2424
- The feature must work fully on the following CPython versions:
25-
3.7, 3.8, 3.9, 3.10, 3.11 and 3.12 on both UNIX and Windows.
25+
3.7, 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13 on both UNIX and Windows.
2626

2727
- The feature must not add unnecessary dependencies (where
2828
"unnecessary" is of course subjective, but new dependencies should

noxfile.py

Lines changed: 95 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# Generated by synthtool. DO NOT EDIT!
18-
1917
from __future__ import absolute_import
2018
import os
2119
import pathlib
20+
import re
2221
import shutil
2322

2423
import nox
@@ -29,16 +28,27 @@
2928

3029
DEFAULT_PYTHON_VERSION = "3.8"
3130
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"]
32-
UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
31+
UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
3332
CONFORMANCE_TEST_PYTHON_VERSIONS = ["3.8"]
3433

35-
_DEFAULT_STORAGE_HOST = "https://storage.googleapis.com"
36-
3734
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
3835

3936
# Error if a python version is missing
4037
nox.options.error_on_missing_interpreters = True
4138

39+
nox.options.sessions = [
40+
"blacken",
41+
"conftest_retry",
42+
"docfx",
43+
"docs",
44+
"lint",
45+
"lint_setup_py",
46+
"system",
47+
"unit",
48+
# cover must be last to avoid error `No data to report`
49+
"cover",
50+
]
51+
4252

4353
@nox.session(python=DEFAULT_PYTHON_VERSION)
4454
def lint(session):
@@ -159,8 +169,8 @@ def system(session):
159169
session.install(
160170
"google-cloud-testutils",
161171
"google-cloud-iam",
162-
"google-cloud-pubsub < 2.0.0",
163-
"google-cloud-kms < 2.0dev",
172+
"google-cloud-pubsub",
173+
"google-cloud-kms",
164174
"brotli",
165175
"-c",
166176
constraints_path,
@@ -300,3 +310,81 @@ def docfx(session):
300310
os.path.join("docs", ""),
301311
os.path.join("docs", "_build", "html", ""),
302312
)
313+
314+
315+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
316+
@nox.parametrize(
317+
"protobuf_implementation",
318+
["python", "upb"],
319+
)
320+
def prerelease_deps(session, protobuf_implementation):
321+
"""Run all tests with prerelease versions of dependencies installed."""
322+
323+
# Install all test dependencies
324+
session.install("mock", "pytest", "pytest-cov", "brotli")
325+
326+
# Install dependencies needed for system tests
327+
session.install(
328+
"google-cloud-pubsub",
329+
"google-cloud-kms",
330+
"google-cloud-testutils",
331+
"google-cloud-iam",
332+
)
333+
334+
# Install all dependencies
335+
session.install("-e", ".[protobuf, tracing]")
336+
337+
prerel_deps = [
338+
"google-api-core",
339+
"google-auth",
340+
"google-cloud-core",
341+
"google-crc32c",
342+
"google-resumable-media",
343+
"opentelemetry-api",
344+
"protobuf",
345+
]
346+
347+
package_namespaces = {
348+
"google-api-core": "google.api_core",
349+
"google-auth": "google.auth",
350+
"google-cloud-core": "google.cloud.version",
351+
"opentelemetry-api": "opentelemetry.version",
352+
"protobuf": "google.protobuf",
353+
}
354+
355+
for dep in prerel_deps:
356+
session.install("--pre", "--no-deps", "--upgrade", dep)
357+
print(f"Installed {dep}")
358+
359+
version_namespace = package_namespaces.get(dep)
360+
361+
if version_namespace:
362+
session.run(
363+
"python",
364+
"-c",
365+
f"import {version_namespace}; print({version_namespace}.__version__)",
366+
)
367+
# Remaining dependencies
368+
other_deps = [
369+
"requests",
370+
]
371+
session.install(*other_deps)
372+
373+
session.run(
374+
"py.test",
375+
"tests/unit",
376+
env={
377+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
378+
},
379+
)
380+
381+
session.run(
382+
"py.test",
383+
"--verbose",
384+
f"--junitxml=system_{session.python}_sponge_log.xml",
385+
os.path.join("tests", "system"),
386+
*session.posargs,
387+
env={
388+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
389+
},
390+
)

owlbot.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626
templated_files = common.py_library(
2727
cov_level=100,
2828
split_system_tests=True,
29-
system_test_external_dependencies=[
30-
"google-cloud-iam",
31-
"google-cloud-pubsub < 2.0.0",
32-
# See: https://github.com/googleapis/python-storage/issues/226
33-
"google-cloud-kms < 2.0dev",
34-
],
3529
intersphinx_dependencies={
3630
# python-requests url temporary change related to
3731
# https://github.com/psf/requests/issues/6140#issuecomment-1135071992
@@ -48,7 +42,8 @@
4842
"README.rst",
4943
".kokoro/continuous/continuous.cfg",
5044
".kokoro/presubmit/system-3.8.cfg",
51-
".kokoro/samples/python3.6", # remove python 3.6 support
45+
".kokoro/presubmit/prerelease-deps.cfg",
46+
".kokoro/continuous/prerelease-deps.cfg",
5247
".github/blunderbuss.yml", # blunderbuss assignment to python squad
5348
".github/workflows", # exclude gh actions as credentials are needed for tests
5449
".github/release-please.yml", # special support for a python2 branch in this repo
@@ -84,12 +79,6 @@
8479
"""omit =
8580
.nox/*""")
8681

87-
s.replace(
88-
".kokoro/release/common.cfg",
89-
'value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"',
90-
'value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem, client-library-test-universe-domain-credential"'
91-
)
92-
9382
python.py_samples(skip_readmes=True)
9483

9584
s.shell.run(["nox", "-s", "blacken"], hide_output=False)

samples/snippets/noxfile_config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,15 @@ def get_cloud_kms_key():
7373
if session == 'py-3.12':
7474
return ('projects/python-docs-samples-tests-312/locations/us/'
7575
'keyRings/gcs-kms-key-ring/cryptoKeys/gcs-kms-key')
76+
if session == 'py-3.13':
77+
return ('projects/python-docs-samples-tests-313/locations/us/'
78+
'keyRings/gcs-kms-key-ring/cryptoKeys/gcs-kms-key')
7679
return os.environ['CLOUD_KMS_KEY']
7780

7881

7982
TEST_CONFIG_OVERRIDE = {
8083
# You can opt out from the test for specific Python versions.
81-
'ignored_versions': ["2.7", "3.6", "3.7", "3.11", "3.12"],
84+
'ignored_versions': ["2.7", "3.6", "3.7", "3.11", "3.12", "3.13"],
8285

8386
# An envvar key for determining the project id to use. Change it
8487
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a

setup.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@
2828
# 'Development Status :: 5 - Production/Stable'
2929
release_status = "Development Status :: 5 - Production/Stable"
3030
dependencies = [
31-
"google-auth >= 2.26.1, < 3.0dev",
32-
"google-api-core >= 2.15.0, <3.0.0dev",
33-
"google-cloud-core >= 2.4.2, < 3.0dev",
31+
"google-auth >= 2.26.1, < 3.0.0",
32+
"google-api-core >= 2.15.0, < 3.0.0",
33+
"google-cloud-core >= 2.4.2, < 3.0.0",
3434
# The dependency "google-resumable-media" is no longer used. However, the
3535
# dependency is still included here to accommodate users who may be
3636
# importing exception classes from the google-resumable-media without
3737
# installing it explicitly. See the python-storage README for details on
3838
# exceptions and importing. Users who are not importing
3939
# google-resumable-media classes in their application can safely disregard
4040
# this dependency.
41-
"google-resumable-media >= 2.7.2",
42-
"requests >= 2.18.0, < 3.0.0dev",
43-
"google-crc32c >= 1.0, < 2.0dev",
41+
"google-resumable-media >= 2.7.2, < 3.0.0",
42+
"requests >= 2.22.0, < 3.0.0",
43+
"google-crc32c >= 1.1.3, < 2.0.0",
4444
]
4545
extras = {
46-
"protobuf": ["protobuf<6.0.0dev"],
46+
"protobuf": ["protobuf >= 3.20.2, < 7.0.0"],
4747
"tracing": [
48-
"opentelemetry-api >= 1.1.0",
48+
"opentelemetry-api >= 1.1.0, < 2.0.0",
4949
],
5050
}
5151

@@ -93,6 +93,7 @@
9393
"Programming Language :: Python :: 3.10",
9494
"Programming Language :: Python :: 3.11",
9595
"Programming Language :: Python :: 3.12",
96+
"Programming Language :: Python :: 3.13",
9697
"Operating System :: OS Independent",
9798
"Topic :: Internet",
9899
],

testing/constraints-3.13.txt

Whitespace-only changes.

testing/constraints-3.7.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This constraints file is used to check that lower bounds
2+
# are correct in setup.py
3+
# List all library dependencies and extras in this file.
4+
# Pin the version to the lower bound.
5+
# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0",
6+
# Then this file should have google-cloud-foo==1.14.0
7+
google-auth==2.26.1
8+
google-api-core==2.15.0
9+
google-cloud-core==2.4.2
10+
google-resumable-media==2.7.2
11+
requests==2.22.0
12+
google-crc32c==1.1.3
13+
protobuf==3.20.2
14+
opentelemetry-api==1.1.0
15+

tests/system/test_notification.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ def topic_path(storage_client, topic_name):
5959

6060
@pytest.fixture(scope="session")
6161
def notification_topic(storage_client, publisher_client, topic_path, no_mtls):
62-
_helpers.retry_429(publisher_client.create_topic)(topic_path)
63-
policy = publisher_client.get_iam_policy(topic_path)
62+
_helpers.retry_429(publisher_client.create_topic)(request={"name": topic_path})
63+
policy = publisher_client.get_iam_policy(request={"resource": topic_path})
6464
binding = policy.bindings.add()
6565
binding.role = "roles/pubsub.publisher"
6666
binding.members.append(
6767
f"serviceAccount:{storage_client.get_service_account_email()}"
6868
)
69-
publisher_client.set_iam_policy(topic_path, policy)
69+
publisher_client.set_iam_policy(request={"resource": topic_path, "policy": policy})
7070

7171

7272
def test_notification_create_minimal(

0 commit comments

Comments
 (0)