Skip to content

fix(templates): resolve core dependencies locally and batch pip installs#17032

Open
ohmayr wants to merge 5 commits into
mainfrom
update-core-deps-nox-session
Open

fix(templates): resolve core dependencies locally and batch pip installs#17032
ohmayr wants to merge 5 commits into
mainfrom
update-core-deps-nox-session

Conversation

@ohmayr
Copy link
Copy Markdown
Contributor

@ohmayr ohmayr commented May 11, 2026

fix(templates): resolve core dependencies locally and batch pip installs

Previously, the core_deps_from_source and prerelease_deps nox sessions installed core sibling packages sequentially. In a monorepo environment, this caused two major issues:

  1. Correctness: It frequently fetched remote upstream code (or PyPI releases) instead of testing the actual local code modified in the active PR.
  2. Performance: Sequential pip install commands triggered strict dependency resolution repeatedly, leading to severe CI timeouts.

This updates the noxfile template to:

  • Dynamically resolve first-party dependencies from the local packages/ directory to guarantee the presubmit tests the active PR's code.
  • Batch the pip install commands using --no-deps and --ignore-installed to bypass the resolver overhead and eliminate the sequential network bottleneck.
  • Dynamically sort packages in prerelease_deps into local vs. PyPI deployments using a regex parser, ensuring safe handling of complex version bounds (e.g., grpcio>=1.75.1) without hardcoding multiple lists.

@ohmayr ohmayr requested a review from a team as a code owner May 11, 2026 20:42
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the noxfile.py template and its corresponding golden files to install core dependencies from local paths instead of remote git repositories. Feedback indicates that a comment needs updating to reflect the new variable name core_packages. Additionally, the logic for locating the packages directory is currently too simplistic and will fail for nested golden files; a more robust traversal method was suggested to ensure the correct path is resolved.

"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_packages = [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable has been renamed to core_packages, but the comment on lines 596-597 still refers to the old name core_dependencies_from_source. Please update the comment to maintain consistency.

for dep in core_dependencies_from_source:
session.install(dep, "--no-deps", "--ignore-installed")
print(f"Installed {dep}")
packages_dir = CURRENT_DIRECTORY.parent
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using CURRENT_DIRECTORY.parent assumes the package is always a direct child of the packages/ directory. This logic fails for generated golden files used in integration tests (e.g., packages/gapic-generator/tests/integration/goldens/asset/noxfile.py), as they are nested deeper. This will cause the core_deps_from_source session to fail when run on goldens. Consider a more robust way to locate the packages directory.

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

@ohmayr ohmayr changed the title chore(templates): resolve core dependencies from local sibling paths fix(templates): resolve core dependencies locally and batch pip installs May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant