2727
2828import nox
2929
30+
3031BLACK_VERSION = "black[jupyter]==23.7.0"
3132ISORT_VERSION = "isort==5.11.0"
3233
@@ -385,7 +386,7 @@ def prerelease_deps(session, protobuf_implementation):
385386 """
386387 Run all tests with pre-release versions of dependencies installed
387388 rather than the standard non pre-release versions.
388- Pre-releases versions can be installed using
389+ Pre-release versions can be installed using
389390 `pip install --pre <package>`.
390391 """
391392
@@ -395,16 +396,16 @@ def prerelease_deps(session, protobuf_implementation):
395396 # Install all dependencies
396397 session .install ("-e" , "." )
397398
398- unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
399399 # Install dependencies for the unit test environment
400+ unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
400401 session .install (* unit_deps_all )
401402
403+ # Install dependencies for the system test environment
402404 system_deps_all = (
403405 SYSTEM_TEST_STANDARD_DEPENDENCIES
404406 + SYSTEM_TEST_EXTERNAL_DEPENDENCIES
405407 + SYSTEM_TEST_EXTRAS
406408 )
407- # Install dependencies for the system test environment
408409 session .install (* system_deps_all )
409410
410411 # Because we test minimum dependency versions on the minimum Python
@@ -429,37 +430,47 @@ def prerelease_deps(session, protobuf_implementation):
429430 # Install dependencies specified in `testing/constraints-X.txt`.
430431 session .install (* constraints_deps )
431432
433+ # Note: If a dependency is added to the `prerel_deps` list,
434+ # the `core_dependencies_from_source` list in the `core_deps_from_source`
435+ # nox session should also be updated.
432436 prerel_deps = [
433- "protobuf" ,
434- # dependency of grpc
435- "six" ,
436- "grpc-google-iam-v1" ,
437437 "googleapis-common-protos" ,
438- "grpcio" ,
439- "grpcio-status" ,
440438 "google-api-core" ,
441439 "google-auth" ,
440+ "grpc-google-iam-v1" ,
441+ "grpcio" ,
442+ "grpcio-status" ,
443+ "protobuf" ,
442444 "proto-plus" ,
443- "google-cloud-testutils" ,
444- # dependencies of google-cloud-testutils"
445- "click" ,
446445 ]
447446
448447 for dep in prerel_deps :
449- session .install ("--pre" , "--no-deps" , "--upgrade" , dep )
450-
451- # Remaining dependencies
452- other_deps = [
453- "requests" ,
454- ]
455- session .install (* other_deps )
456-
457- # Print out prerelease package versions
458- session .run (
459- "python" , "-c" , "import google.protobuf; print(google.protobuf.__version__)"
460- )
461- session .run ("python" , "-c" , "import grpc; print(grpc.__version__)" )
462- session .run ("python" , "-c" , "import google.auth; print(google.auth.__version__)" )
448+ session .install ("--pre" , "--no-deps" , "--ignore-installed" , dep )
449+ # TODO(https://github.com/grpc/grpc/issues/38965): Add `grpcio-status``
450+ # to the dictionary below once this bug is fixed.
451+ # TODO(https://github.com/googleapis/google-cloud-python/issues/13643): Add
452+ # `googleapis-common-protos` and `grpc-google-iam-v1` to the dictionary below
453+ # once this bug is fixed.
454+ package_namespaces = {
455+ "google-api-core" : "google.api_core" ,
456+ "google-auth" : "google.auth" ,
457+ "grpcio" : "grpc" ,
458+ "protobuf" : "google.protobuf" ,
459+ "proto-plus" : "proto" ,
460+ }
461+
462+ try :
463+ version_namespace = package_namespaces [dep ]
464+ except KeyError :
465+ version_namespace = None
466+
467+ print (f"Installed { dep } " )
468+ if version_namespace :
469+ session .run (
470+ "python" ,
471+ "-c" ,
472+ f"import { version_namespace } ; print({ version_namespace } .__version__)" ,
473+ )
463474
464475 session .run (
465476 "py.test" ,
@@ -476,12 +487,12 @@ def prerelease_deps(session, protobuf_implementation):
476487 ["python" , "upb" ],
477488)
478489def core_deps_from_source (session , protobuf_implementation ):
479- """Run all tests with local versions of core dependencies installed,
480- rather than pulling core dependencies from PyPI.
490+ """Run all tests with core dependencies installed from source
491+ rather than pulling the dependencies from PyPI.
481492 """
482493
483494 # Install all dependencies
484- session .install ("." )
495+ session .install ("-e" , " ." )
485496
486497 # Install dependencies for the unit test environment
487498 unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
@@ -497,7 +508,7 @@ def core_deps_from_source(session, protobuf_implementation):
497508
498509 # Because we test minimum dependency versions on the minimum Python
499510 # version, the first version we test with in the unit tests sessions has a
500- # constraints file containing all dependencies and extras that should be installed .
511+ # constraints file containing all dependencies and extras.
501512 with open (
502513 CURRENT_DIRECTORY
503514 / "testing"
@@ -517,16 +528,23 @@ def core_deps_from_source(session, protobuf_implementation):
517528 # Install dependencies specified in `testing/constraints-X.txt`.
518529 session .install (* constraints_deps )
519530
531+ # TODO(hhttps://github.com/googleapis/gapic-generator-python/issues/2358): `grpcio` and
532+ # `grpcio-status` should be added to the list below so that it is installed from source, rather than PyPI
533+ # TODO(https://github.com/googleapis/gapic-generator-python/issues/2357): `protobuf` should be
534+ # added to the list below so that it is installed from source, rather than PyPI
535+ # Note: If a dependency is added to the `core_dependencies_from_source` list,
536+ # the `prerel_deps` list in the `prerelease_deps` nox session should also be updated.
520537 core_dependencies_from_source = [
538+ "proto-plus @ git+https://github.com/googleapis/proto-plus-python.git" ,
539+ f"{ CURRENT_DIRECTORY } /../googleapis-common-protos" ,
521540 "google-api-core @ git+https://github.com/googleapis/python-api-core.git" ,
522541 "google-auth @ git+https://github.com/googleapis/google-auth-library-python.git" ,
523- f"{ CURRENT_DIRECTORY } /../googleapis-common-protos" ,
524542 f"{ CURRENT_DIRECTORY } /../grpc-google-iam-v1" ,
525- "proto-plus @ git+https://github.com/googleapis/proto-plus-python.git" ,
526543 ]
527544
528545 for dep in core_dependencies_from_source :
529- session .install (dep , "--ignore-installed" , "--no-deps" )
546+ session .install (dep , "--no-deps" , "--ignore-installed" )
547+ print (f"Installed { dep } " )
530548
531549 session .run (
532550 "py.test" ,
0 commit comments