Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 55 additions & 35 deletions packages/bigquery-magics/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,47 +455,67 @@ def prerelease_deps(session):
session.install(*constraints_deps)

prerel_deps = [
"protobuf",
# dependency of grpc
"six",
"grpc-google-iam-v1",
"googleapis-common-protos",
"grpcio",
"grpcio-status",
"google-api-core",
"google-auth",
"grpc-google-iam-v1",
"grpcio>=1.75.1" if session.python >= "3.12" else "grpcio<=1.62.2",
"grpcio-status",
"protobuf",
"proto-plus",
"google-cloud-testutils",
# dependencies of google-cloud-testutils"
"click",
]

for dep in prerel_deps:
session.install("--pre", "--no-deps", "--upgrade", dep)

# Remaining dependencies
other_deps = [
"requests",
]
session.install(*other_deps)

# Install spanner-graph-notebook, python-bigquery, and python-bigquery-storage
# from main to detect any potential breaking changes. For context, see:
# https://github.com/googleapis/python-bigquery-pandas/issues/854
session.install(
"--ignore-installed",
# TODO(https://github.com/googleapis/google-cloud-python/pull/126): Install this again when we relax the pin.
# "https://github.com/cloudspannerecosystem/spanner-graph-notebook/archive/refs/heads/main.zip",
f"{CURRENT_DIRECTORY}/../google-cloud-bigquery",
f"{CURRENT_DIRECTORY}/../google-cloud-bigquery-storage",
)
# Print out prerelease package versions
session.run("pip", "freeze")
session.run(
"python", "-c", "import google.protobuf; print(google.protobuf.__version__)"
)
session.run("python", "-c", "import grpc; print(grpc.__version__)")
session.run("python", "-c", "import google.auth; print(google.auth.__version__)")
deps_dir = CURRENT_DIRECTORY.parent
while deps_dir.name != "packages" and deps_dir.parent != deps_dir:
deps_dir = deps_dir.parent

# Extract the base package name, safely ignoring version bounds and spaces
# (e.g., "grpcio>=1.75.1" becomes "grpcio")
parsed_deps = {
dep: re.match(r"^([a-zA-Z0-9_-]+)", dep).group(1)
for dep in prerel_deps
}

# Dynamically sort local packages vs PyPI dependencies
local_paths = []
pypi_deps = []

for dep, pkg_name in parsed_deps.items():
if (deps_dir / pkg_name).exists():
local_paths.append(str(deps_dir / pkg_name))
else:
pypi_deps.append(dep)

# Batch pip installations for maximum speed
if local_paths:
session.install(*local_paths, "--no-deps", "--ignore-installed")
if pypi_deps:
session.install(*pypi_deps, "--pre", "--no-deps", "--ignore-installed")

# TODO(https://github.com/grpc/grpc/issues/38965): Add `grpcio-status`
# to the dictionary below once this bug is fixed.
# TODO(https://github.com/googleapis/google-cloud-python/issues/13643): Add
# `googleapis-common-protos` and `grpc-google-iam-v1` to the dictionary below
# once this bug is fixed.
package_namespaces = {
"google-api-core": "google.api_core",
"google-auth": "google.auth",
"grpcio": "grpc",
"protobuf": "google.protobuf",
"proto-plus": "proto",
}

# Reuse the parsed names for logging and version verification
for dep, pkg_name in parsed_deps.items():
print(f"Installed {dep}")
version_namespace = package_namespaces.get(pkg_name)

if version_namespace:
session.run(
"python",
"-c",
f"import {version_namespace}; print({version_namespace}.__version__)",
)

session.run(
"py.test",
Expand Down
9 changes: 9 additions & 0 deletions packages/gapic-generator/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,12 @@ switched_rules_by_language(
gapic = True,
grpc = True,
)

# BEGIN workaround
load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
name = "python311",
python_version = "3.11",
)
# END workaround
85 changes: 59 additions & 26 deletions packages/gapic-generator/gapic/templates/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -509,24 +509,51 @@ def prerelease_deps(session, protobuf_implementation):
"proto-plus",
]

for dep in prerel_deps:
session.install("--pre", "--no-deps", "--ignore-installed", dep)
# TODO(https://github.com/grpc/grpc/issues/38965): Add `grpcio-status``
# to the dictionary below once this bug is fixed.
# TODO(https://github.com/googleapis/google-cloud-python/issues/13643): Add
# `googleapis-common-protos` and `grpc-google-iam-v1` to the dictionary below
# once this bug is fixed.
package_namespaces = {
"google-api-core": "google.api_core",
"google-auth": "google.auth",
"grpcio": "grpc",
"protobuf": "google.protobuf",
"proto-plus": "proto",
}

version_namespace = package_namespaces.get(dep)

deps_dir = CURRENT_DIRECTORY.parent
while deps_dir.name != "packages" and deps_dir.parent != deps_dir:
deps_dir = deps_dir.parent

# Extract the base package name, safely ignoring version bounds and spaces
# (e.g., "grpcio>=1.75.1" becomes "grpcio")
parsed_deps = {
dep: re.match(r"^([a-zA-Z0-9_-]+)", dep).group(1)
for dep in prerel_deps
}

# Dynamically sort local packages vs PyPI dependencies
local_paths = []
pypi_deps = []

for dep, pkg_name in parsed_deps.items():
if (deps_dir / pkg_name).exists():
local_paths.append(str(deps_dir / pkg_name))
else:
pypi_deps.append(dep)

# Batch pip installations to avoid sequential overhead
if local_paths:
session.install(*local_paths, "--no-deps", "--ignore-installed")
if pypi_deps:
session.install(*pypi_deps, "--pre", "--no-deps", "--ignore-installed")

# TODO(https://github.com/grpc/grpc/issues/38965): Add `grpcio-status``
# to the dictionary below once this bug is fixed.
# TODO(https://github.com/googleapis/google-cloud-python/issues/13643): Add
# `googleapis-common-protos` and `grpc-google-iam-v1` to the dictionary below
# once this bug is fixed.
package_namespaces = {
"google-api-core": "google.api_core",
"google-auth": "google.auth",
"grpcio": "grpc",
"protobuf": "google.protobuf",
"proto-plus": "proto",
}

# Reuse the parsed names for logging and version verification
for dep, pkg_name in parsed_deps.items():
print(f"Installed {dep}")
version_namespace = package_namespaces.get(pkg_name)

if version_namespace:
session.run(
"python",
Expand Down Expand Up @@ -595,17 +622,23 @@ def core_deps_from_source(session, protobuf_implementation):
# added to the list below so that it is installed from source, rather than PyPI
# Note: If a dependency is added to the `core_dependencies_from_source` list,
# the `prerel_deps` list in the `prerelease_deps` nox session should also be updated.
core_dependencies_from_source = [
"googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos",
"google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core",
"google-auth @ git+https://github.com/googleapis/google-cloud-python#egg=google-auth&subdirectory=packages/google-auth",
"grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1",
"proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus",
core_dependencies_from_source = [
"googleapis-common-protos",
"google-api-core",
"google-auth",
"grpc-google-iam-v1",
"proto-plus",
]

for dep in core_dependencies_from_source:
session.install(dep, "--no-deps", "--ignore-installed")
print(f"Installed {dep}")
deps_dir = CURRENT_DIRECTORY.parent
while deps_dir.name != "packages" and deps_dir.parent != deps_dir:
deps_dir = deps_dir.parent

# Batch the pip installation to avoid sequential overhead
dep_paths = [str(deps_dir / dep) for dep in core_dependencies_from_source]

session.install(*dep_paths, "--no-deps", "--ignore-installed")
print(f"Installed {', '.join(core_dependencies_from_source)} locally from {deps_dir}")

session.run(
"py.test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,24 +501,51 @@ def prerelease_deps(session, protobuf_implementation):
"proto-plus",
]

for dep in prerel_deps:
session.install("--pre", "--no-deps", "--ignore-installed", dep)
# TODO(https://github.com/grpc/grpc/issues/38965): Add `grpcio-status``
# to the dictionary below once this bug is fixed.
# TODO(https://github.com/googleapis/google-cloud-python/issues/13643): Add
# `googleapis-common-protos` and `grpc-google-iam-v1` to the dictionary below
# once this bug is fixed.
package_namespaces = {
"google-api-core": "google.api_core",
"google-auth": "google.auth",
"grpcio": "grpc",
"protobuf": "google.protobuf",
"proto-plus": "proto",
}

version_namespace = package_namespaces.get(dep)

deps_dir = CURRENT_DIRECTORY.parent
while deps_dir.name != "packages" and deps_dir.parent != deps_dir:
deps_dir = deps_dir.parent

# Extract the base package name, safely ignoring version bounds and spaces
# (e.g., "grpcio>=1.75.1" becomes "grpcio")
parsed_deps = {
dep: re.match(r"^([a-zA-Z0-9_-]+)", dep).group(1)
for dep in prerel_deps
}

# Dynamically sort local packages vs PyPI dependencies
local_paths = []
pypi_deps = []

for dep, pkg_name in parsed_deps.items():
if (deps_dir / pkg_name).exists():
local_paths.append(str(deps_dir / pkg_name))
else:
pypi_deps.append(dep)

# Batch pip installations to avoid sequential overhead
if local_paths:
session.install(*local_paths, "--no-deps", "--ignore-installed")
if pypi_deps:
session.install(*pypi_deps, "--pre", "--no-deps", "--ignore-installed")

# TODO(https://github.com/grpc/grpc/issues/38965): Add `grpcio-status``
# to the dictionary below once this bug is fixed.
# TODO(https://github.com/googleapis/google-cloud-python/issues/13643): Add
# `googleapis-common-protos` and `grpc-google-iam-v1` to the dictionary below
# once this bug is fixed.
package_namespaces = {
"google-api-core": "google.api_core",
"google-auth": "google.auth",
"grpcio": "grpc",
"protobuf": "google.protobuf",
"proto-plus": "proto",
}

# Reuse the parsed names for logging and version verification
for dep, pkg_name in parsed_deps.items():
print(f"Installed {dep}")
version_namespace = package_namespaces.get(pkg_name)

if version_namespace:
session.run(
"python",
Expand Down Expand Up @@ -588,16 +615,22 @@ def core_deps_from_source(session, protobuf_implementation):
# Note: If a dependency is added to the `core_dependencies_from_source` list,
# the `prerel_deps` list in the `prerelease_deps` nox session should also be updated.
core_dependencies_from_source = [
"googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos",
"google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core",
"google-auth @ git+https://github.com/googleapis/google-cloud-python#egg=google-auth&subdirectory=packages/google-auth",
"grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1",
"proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus",
"googleapis-common-protos",
"google-api-core",
"google-auth",
"grpc-google-iam-v1",
"proto-plus",
]

for dep in core_dependencies_from_source:
session.install(dep, "--no-deps", "--ignore-installed")
print(f"Installed {dep}")
deps_dir = CURRENT_DIRECTORY.parent
while deps_dir.name != "packages" and deps_dir.parent != deps_dir:
deps_dir = deps_dir.parent

# Batch the pip installation to avoid sequential overhead
dep_paths = [str(deps_dir / dep) for dep in core_dependencies_from_source]

session.install(*dep_paths, "--no-deps", "--ignore-installed")
print(f"Installed {', '.join(core_dependencies_from_source)} locally from {deps_dir}")

session.run(
"py.test",
Expand Down
Loading
Loading