Skip to content

Commit

Permalink
fix: Allow Protobuf 5.x (#991)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
parthea and gcf-owl-bot[bot] authored Jul 5, 2024
1 parent 90f9721 commit 5812a3c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
78 changes: 78 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import os
import pathlib
import re
import shutil
import signal
import subprocess
Expand Down Expand Up @@ -74,6 +75,83 @@ def default(session):
)


@nox.session(python="3.12")
@nox.parametrize(
"protobuf_implementation",
["python", "upb", "cpp"],
)
def prerelease_deps(session, protobuf_implementation):
"""Run all tests with prerelease versions of dependencies installed."""

if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
session.skip("cpp implementation is not supported in python 3.11+")

# Install all dependencies
session.install("-e", ".[all, tests, tracing]")
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES
session.install(*unit_deps_all)

# Because we test minimum dependency versions on the minimum Python
# version, the first version we test with in the unit tests sessions has a
# constraints file containing all dependencies and extras.
with open(
CURRENT_DIRECTORY / "testing" / f"constraints-{ALL_INTERPRETERS[0]}.txt",
encoding="utf-8",
) as constraints_file:
constraints_text = constraints_file.read()

# Ignore leading whitespace and comment lines.
constraints_deps = [
match.group(1)
for match in re.finditer(
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
)
]

session.install(*constraints_deps)

prerel_deps = [
"protobuf",
# dependency of grpc
"six",
"grpc-google-iam-v1",
"google-cloud-datastore",
"googleapis-common-protos",
"grpcio",
"grpcio-status",
"google-api-core",
"google-auth",
"proto-plus",
"google-cloud-testutils",
# dependencies of google-cloud-testutils"
"click",
]

for dep in prerel_deps:
session.install("--pre", "--no-deps", "--upgrade", dep)

# Remaining dependencies
other_deps = [
"requests",
]
session.install(*other_deps)

# Print out prerelease package versions
session.run(
"python", "-c", "import google.protobuf; print(google.protobuf.__version__)"
)
session.run("python", "-c", "import grpc; print(grpc.__version__)")
session.run("python", "-c", "import google.auth; print(google.auth.__version__)")

session.run(
"py.test",
"tests/unit",
env={
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
},
)


@nox.session(python=ALL_INTERPRETERS)
def unit(session):
"""Run the unit test suite."""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main():
dependencies = [
"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.*",
"google-cloud-datastore >= 2.16.0, < 3.0.0dev",
"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",
"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",
"pymemcache >= 2.1.0, < 5.0.0dev",
"pytz >= 2018.3",
"redis >= 3.0.0, < 6.0.0dev",
Expand Down
2 changes: 1 addition & 1 deletion testing/constraints-3.7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Then this file should have foo==1.14.0
google-cloud-datastore==2.16.0
google-api-core==1.34.0
protobuf==3.19.5
protobuf==3.20.2
pymemcache==2.1.0
redis==3.0.0
pytz==2018.3
Expand Down

0 comments on commit 5812a3c

Please sign in to comment.