Skip to content

Commit 1848098

Browse files
committed
fix build
1 parent 5b266ea commit 1848098

1 file changed

Lines changed: 103 additions & 0 deletions

File tree

packages/google-cloud-runtimeconfig/noxfile.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,3 +476,106 @@ def prerelease_deps(session, protobuf_implementation):
476476
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
477477
},
478478
)
479+
480+
@nox.session(python=DEFAULT_PYTHON_VERSION)
481+
@nox.parametrize(
482+
"protobuf_implementation",
483+
["python", "upb", "cpp"],
484+
)
485+
def core_deps_from_source(session, protobuf_implementation):
486+
"""Run all tests with core dependencies installed from source
487+
rather than pulling the dependencies from PyPI."""
488+
489+
if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13", "3.14"):
490+
session.skip("cpp implementation is not supported in python 3.11+")
491+
492+
# Install all dependencies
493+
session.install("-e", ".[all, tests, tracing]")
494+
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
495+
session.install(*unit_deps_all)
496+
system_deps_all = (
497+
SYSTEM_TEST_STANDARD_DEPENDENCIES + SYSTEM_TEST_EXTERNAL_DEPENDENCIES
498+
)
499+
session.install(*system_deps_all)
500+
501+
# Because we test minimum dependency versions on the minimum Python
502+
# version, the first version we test with in the unit tests sessions has a
503+
# constraints file containing all dependencies and extras.
504+
with open(
505+
CURRENT_DIRECTORY
506+
/ "testing"
507+
/ f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt",
508+
encoding="utf-8",
509+
) as constraints_file:
510+
constraints_text = constraints_file.read()
511+
512+
# Ignore leading whitespace and comment lines.
513+
constraints_deps = [
514+
match.group(1)
515+
for match in re.finditer(
516+
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
517+
)
518+
]
519+
520+
session.install(*constraints_deps)
521+
522+
# Note: If a dependency is added to the `core_dependencies_from_source` list,
523+
# the `prerel_deps` list in the `prerelease_deps` nox session should also be updated.
524+
core_dependencies_from_source = [
525+
"googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos",
526+
"google-api-core @ git+https://github.com/googleapis/python-api-core.git",
527+
"google-auth @ git+https://github.com/googleapis/google-auth-library-python.git",
528+
"grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1",
529+
"proto-plus @ git+https://github.com/googleapis/proto-plus-python.git",
530+
]
531+
532+
for dep in core_dependencies_from_source:
533+
session.install("--pre", "--no-deps", "--upgrade", dep)
534+
535+
# Remaining dependencies
536+
other_deps = [
537+
"requests",
538+
]
539+
session.install(*other_deps)
540+
541+
# Print out package versions
542+
session.run(
543+
"python", "-c", "import google.protobuf; print(google.protobuf.__version__)"
544+
)
545+
session.run("python", "-c", "import grpc; print(grpc.__version__)")
546+
session.run("python", "-c", "import google.auth; print(google.auth.__version__)")
547+
548+
session.run(
549+
"py.test",
550+
"tests/unit",
551+
env={
552+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
553+
},
554+
)
555+
556+
system_test_path = os.path.join("tests", "system.py")
557+
system_test_folder_path = os.path.join("tests", "system")
558+
559+
# Only run system tests if found.
560+
if os.path.exists(system_test_path):
561+
session.run(
562+
"py.test",
563+
"--verbose",
564+
f"--junitxml=system_{session.python}_sponge_log.xml",
565+
system_test_path,
566+
*session.posargs,
567+
env={
568+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
569+
},
570+
)
571+
if os.path.exists(system_test_folder_path):
572+
session.run(
573+
"py.test",
574+
"--verbose",
575+
f"--junitxml=system_{session.python}_sponge_log.xml",
576+
system_test_folder_path,
577+
*session.posargs,
578+
env={
579+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
580+
},
581+
)

0 commit comments

Comments
 (0)