Skip to content

Commit 5812a3c

Browse files
fix: Allow Protobuf 5.x (#991)
* fix: Allow Protobuf 5.x * add prerelease nox session * 🦉 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 90f9721 commit 5812a3c

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

noxfile.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import os
2121
import pathlib
22+
import re
2223
import shutil
2324
import signal
2425
import subprocess
@@ -74,6 +75,83 @@ def default(session):
7475
)
7576

7677

78+
@nox.session(python="3.12")
79+
@nox.parametrize(
80+
"protobuf_implementation",
81+
["python", "upb", "cpp"],
82+
)
83+
def prerelease_deps(session, protobuf_implementation):
84+
"""Run all tests with prerelease versions of dependencies installed."""
85+
86+
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
87+
session.skip("cpp implementation is not supported in python 3.11+")
88+
89+
# Install all dependencies
90+
session.install("-e", ".[all, tests, tracing]")
91+
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES
92+
session.install(*unit_deps_all)
93+
94+
# Because we test minimum dependency versions on the minimum Python
95+
# version, the first version we test with in the unit tests sessions has a
96+
# constraints file containing all dependencies and extras.
97+
with open(
98+
CURRENT_DIRECTORY / "testing" / f"constraints-{ALL_INTERPRETERS[0]}.txt",
99+
encoding="utf-8",
100+
) as constraints_file:
101+
constraints_text = constraints_file.read()
102+
103+
# Ignore leading whitespace and comment lines.
104+
constraints_deps = [
105+
match.group(1)
106+
for match in re.finditer(
107+
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
108+
)
109+
]
110+
111+
session.install(*constraints_deps)
112+
113+
prerel_deps = [
114+
"protobuf",
115+
# dependency of grpc
116+
"six",
117+
"grpc-google-iam-v1",
118+
"google-cloud-datastore",
119+
"googleapis-common-protos",
120+
"grpcio",
121+
"grpcio-status",
122+
"google-api-core",
123+
"google-auth",
124+
"proto-plus",
125+
"google-cloud-testutils",
126+
# dependencies of google-cloud-testutils"
127+
"click",
128+
]
129+
130+
for dep in prerel_deps:
131+
session.install("--pre", "--no-deps", "--upgrade", dep)
132+
133+
# Remaining dependencies
134+
other_deps = [
135+
"requests",
136+
]
137+
session.install(*other_deps)
138+
139+
# Print out prerelease package versions
140+
session.run(
141+
"python", "-c", "import google.protobuf; print(google.protobuf.__version__)"
142+
)
143+
session.run("python", "-c", "import grpc; print(grpc.__version__)")
144+
session.run("python", "-c", "import google.auth; print(google.auth.__version__)")
145+
146+
session.run(
147+
"py.test",
148+
"tests/unit",
149+
env={
150+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
151+
},
152+
)
153+
154+
77155
@nox.session(python=ALL_INTERPRETERS)
78156
def unit(session):
79157
"""Run the unit test suite."""

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def main():
4242
dependencies = [
4343
"google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*",
4444
"google-cloud-datastore >= 2.16.0, < 3.0.0dev",
45-
"protobuf >= 3.19.5, <5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
45+
"protobuf >= 3.20.2, <6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
4646
"pymemcache >= 2.1.0, < 5.0.0dev",
4747
"pytz >= 2018.3",
4848
"redis >= 3.0.0, < 6.0.0dev",

testing/constraints-3.7.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Then this file should have foo==1.14.0
88
google-cloud-datastore==2.16.0
99
google-api-core==1.34.0
10-
protobuf==3.19.5
10+
protobuf==3.20.2
1111
pymemcache==2.1.0
1212
redis==3.0.0
1313
pytz==2018.3

0 commit comments

Comments
 (0)