|
33 | 33 | # Black and flake8 clash on the syntax for ignoring flake8's F401 in this file. |
34 | 34 | BLACK_EXCLUDES = ["--exclude", "^/google/api_core/operations_v1/__init__.py"] |
35 | 35 |
|
36 | | -PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] |
| 36 | +ALL_PYTHON = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] |
| 37 | +SUPPORTED_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] |
37 | 38 |
|
38 | 39 | DEFAULT_PYTHON_VERSION = "3.14" |
39 | 40 | CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() |
@@ -106,7 +107,49 @@ def install_prerelease_dependencies(session, constraints_path): |
106 | 107 | session.install(*other_deps) |
107 | 108 |
|
108 | 109 |
|
109 | | -def default(session, install_grpc=True, prerelease=False, install_async_rest=False): |
| 110 | +def install_core_deps_dependencies(session, constraints_path): |
| 111 | + with open(constraints_path, encoding="utf-8") as constraints_file: |
| 112 | + constraints_text = constraints_file.read() |
| 113 | + # Ignore leading whitespace and comment lines. |
| 114 | + constraints_deps = [ |
| 115 | + match.group(1) |
| 116 | + for match in re.finditer( |
| 117 | + r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE |
| 118 | + ) |
| 119 | + ] |
| 120 | + if constraints_deps: |
| 121 | + session.install(*constraints_deps) |
| 122 | + |
| 123 | + # Note: If a dependency is added to the `core_dependencies_from_source` list, |
| 124 | + # the `prerel_deps` list in the `install_prerelease_dependencies` method should also be updated. |
| 125 | + core_dependencies_from_source = [ |
| 126 | + "googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos", |
| 127 | + "google-auth @ git+https://github.com/googleapis/google-auth-library-python.git", |
| 128 | + "grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1", |
| 129 | + "proto-plus @ git+https://github.com/googleapis/proto-plus-python.git", |
| 130 | + ] |
| 131 | + |
| 132 | + for dep in core_dependencies_from_source: |
| 133 | + session.install(dep, "--no-deps", "--ignore-installed") |
| 134 | + print(f"Installed {dep}") |
| 135 | + |
| 136 | + # Remaining dependencies |
| 137 | + other_deps = [ |
| 138 | + "requests", |
| 139 | + "pyasn1", |
| 140 | + "cryptography", |
| 141 | + "cachetools", |
| 142 | + ] |
| 143 | + session.install(*other_deps) |
| 144 | + |
| 145 | + |
| 146 | +def default( |
| 147 | + session, |
| 148 | + install_grpc=True, |
| 149 | + prerelease=False, |
| 150 | + install_async_rest=False, |
| 151 | + install_deps_from_source=False, |
| 152 | +): |
110 | 153 | """Default unit test session. |
111 | 154 |
|
112 | 155 | This is intended to be run **without** an interpreter set, so |
@@ -139,7 +182,14 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal |
139 | 182 | if prerelease: |
140 | 183 | install_prerelease_dependencies( |
141 | 184 | session, |
142 | | - f"{constraints_dir}/constraints-{constraints_type}{PYTHON_VERSIONS[0]}.txt", |
| 185 | + f"{constraints_dir}/constraints-{constraints_type}{SUPPORTED_PYTHON_VERSIONS[0]}.txt", |
| 186 | + ) |
| 187 | + # This *must* be the last install command to get the package from source. |
| 188 | + session.install("-e", lib_with_extras, "--no-deps") |
| 189 | + elif install_deps_from_source: |
| 190 | + install_core_deps_dependencies( |
| 191 | + session, |
| 192 | + f"{constraints_dir}/constraints-{constraints_type}{SUPPORTED_PYTHON_VERSIONS[0]}.txt", |
143 | 193 | ) |
144 | 194 | # This *must* be the last install command to get the package from source. |
145 | 195 | session.install("-e", lib_with_extras, "--no-deps") |
@@ -206,7 +256,7 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal |
206 | 256 | session.run(*pytest_args) |
207 | 257 |
|
208 | 258 |
|
209 | | -@nox.session(python=PYTHON_VERSIONS) |
| 259 | +@nox.session(python=ALL_PYTHON) |
210 | 260 | @nox.parametrize( |
211 | 261 | ["install_grpc", "install_async_rest", "python_versions", "legacy_proto"], |
212 | 262 | [ |
@@ -267,7 +317,13 @@ def unit( |
267 | 317 |
|
268 | 318 | @nox.session(python=DEFAULT_PYTHON_VERSION) |
269 | 319 | def prerelease_deps(session): |
270 | | - """Run the unit test suite.""" |
| 320 | + """Run the test suite installing pre-release versions of dependencies.""" |
| 321 | + default(session, prerelease=True) |
| 322 | + |
| 323 | + |
| 324 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 325 | +def core_deps_from_source(session): |
| 326 | + """Run the test suite installing dependencies from source.""" |
271 | 327 | default(session, prerelease=True) |
272 | 328 |
|
273 | 329 |
|
|
0 commit comments