|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from __future__ import absolute_import |
|
|
|
import nox |
|
import pathlib |
|
|
|
|
|
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() |
|
|
|
|
|
PYTHON_VERSIONS = [ |
|
"3.7", |
|
"3.8", |
|
"3.9", |
|
"3.10", |
|
"3.11", |
|
"3.12", |
|
"3.13", |
|
] |
|
|
|
|
|
nox.options.error_on_missing_interpreters = True |
|
|
|
|
|
@nox.session(python=PYTHON_VERSIONS) |
|
@nox.parametrize("implementation", ["cpp", "upb", "python"]) |
|
def unit(session, implementation): |
|
"""Run the unit test suite.""" |
|
|
|
constraints_path = str( |
|
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" |
|
) |
|
|
|
session.env["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = implementation |
|
session.install("coverage", "pytest", "pytest-cov", "pytz") |
|
session.install("-e", ".[testing]", "-c", constraints_path) |
|
|
|
|
|
|
|
if implementation == "cpp": |
|
session.install("protobuf<4") |
|
|
|
|
|
|
|
|
|
|
|
|
|
session.run( |
|
"pytest", |
|
"--quiet", |
|
*( |
|
session.posargs |
|
or [ |
|
"--cov=proto", |
|
"--cov-config=.coveragerc", |
|
"--cov-report=term", |
|
"--cov-report=html", |
|
"tests", |
|
] |
|
), |
|
) |
|
|
|
|
|
|
|
|
|
|
|
@nox.session(python=PYTHON_VERSIONS[-2]) |
|
@nox.parametrize("implementation", ["python", "upb"]) |
|
def prerelease_deps(session, implementation): |
|
"""Run the unit test suite against pre-release versions of dependencies.""" |
|
|
|
session.env["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = implementation |
|
|
|
|
|
session.install("coverage", "pytest", "pytest-cov", "pytz") |
|
|
|
|
|
session.install("-e", ".", "--no-deps") |
|
|
|
prerel_deps = [ |
|
"google-api-core", |
|
|
|
"googleapis-common-protos", |
|
] |
|
|
|
for dep in prerel_deps: |
|
session.install("--pre", "--no-deps", "--upgrade", dep) |
|
|
|
session.install("--pre", "--upgrade", "protobuf") |
|
|
|
session.run( |
|
"python", "-c", "import google.protobuf; print(google.protobuf.__version__)" |
|
) |
|
session.run( |
|
"python", "-c", "import google.api_core; print(google.api_core.__version__)" |
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
session.run( |
|
"pytest", |
|
"--quiet", |
|
*( |
|
session.posargs |
|
or [ |
|
"--cov=proto", |
|
"--cov-config=.coveragerc", |
|
"--cov-report=term", |
|
"--cov-report=html", |
|
"tests", |
|
] |
|
), |
|
) |
|
|
|
|
|
@nox.session(python="3.9") |
|
def docs(session): |
|
"""Build the docs.""" |
|
|
|
session.install( |
|
|
|
|
|
|
|
|
|
"sphinxcontrib-applehelp==1.0.4", |
|
"sphinxcontrib-devhelp==1.0.2", |
|
"sphinxcontrib-htmlhelp==2.0.1", |
|
"sphinxcontrib-qthelp==1.0.3", |
|
"sphinxcontrib-serializinghtml==1.1.5", |
|
"sphinx==4.5.0", |
|
"sphinx_rtd_theme", |
|
) |
|
session.install(".") |
|
|
|
|
|
session.run("rm", "-rf", "docs/_build/") |
|
session.run( |
|
"sphinx-build", |
|
"-W", |
|
"-b", |
|
"html", |
|
"-d", |
|
"docs/_build/doctrees", |
|
"docs/", |
|
"docs/_build/html/", |
|
) |
|
|