Skip to content

Commit 4267bc7

Browse files
committed
add core_deps_from_source nox session
1 parent d6e1ee5 commit 4267bc7

File tree

1 file changed

+61
-5
lines changed

1 file changed

+61
-5
lines changed

packages/google-api-core/noxfile.py

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
# Black and flake8 clash on the syntax for ignoring flake8's F401 in this file.
3434
BLACK_EXCLUDES = ["--exclude", "^/google/api_core/operations_v1/__init__.py"]
3535

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"]
3738

3839
DEFAULT_PYTHON_VERSION = "3.14"
3940
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
@@ -106,7 +107,49 @@ def install_prerelease_dependencies(session, constraints_path):
106107
session.install(*other_deps)
107108

108109

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+
):
110153
"""Default unit test session.
111154
112155
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
139182
if prerelease:
140183
install_prerelease_dependencies(
141184
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",
143193
)
144194
# This *must* be the last install command to get the package from source.
145195
session.install("-e", lib_with_extras, "--no-deps")
@@ -206,7 +256,7 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal
206256
session.run(*pytest_args)
207257

208258

209-
@nox.session(python=PYTHON_VERSIONS)
259+
@nox.session(python=ALL_PYTHON)
210260
@nox.parametrize(
211261
["install_grpc", "install_async_rest", "python_versions", "legacy_proto"],
212262
[
@@ -267,7 +317,13 @@ def unit(
267317

268318
@nox.session(python=DEFAULT_PYTHON_VERSION)
269319
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."""
271327
default(session, prerelease=True)
272328

273329

0 commit comments

Comments
 (0)