Skip to content

feat(spanner): drop support for python 3.9#17043

Draft
chalmerlowe wants to merge 40 commits into
mainfrom
feat/drop-python-3.9-google-cloud-spanner
Draft

feat(spanner): drop support for python 3.9#17043
chalmerlowe wants to merge 40 commits into
mainfrom
feat/drop-python-3.9-google-cloud-spanner

Conversation

@chalmerlowe
Copy link
Copy Markdown
Contributor

This PR updates Python to establish version 3.10 as the minimum supported version.

Changes

  • Configuration: Updated setup.py and noxfile.py to require Python >=3.10 and remove references to older versions.
  • Cleanup: Removed dead code and polyfills no longer needed in tests.

Fixes internal issue: http://b/482126936 🦕

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 drops support for Python 3.9 in the google-cloud-spanner package, updating metadata, documentation, and test configurations to reflect a new minimum requirement of Python 3.10. It also introduces a new version_scanner utility in scripts/ designed to identify hardcoded dependency versions across the repository. Review feedback suggests adding a constraints-3.10.txt file and ensuring a minor version bump for the breaking change. Additionally, improvements were recommended for the scanner tool, including fixing .scannerignore path resolution, supporting nested directory ignores, and documenting required external dependencies in the README.

platforms="Posix; MacOS X; Windows",
packages=packages,
python_requires=">=3.9",
python_requires=">=3.10",
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.

high

Since the minimum supported Python version is being updated to 3.10 and packages/google-cloud-spanner/testing/constraints-3.9.txt is being removed, a corresponding constraints-3.10.txt file should be added. This ensures that the lowest supported runtime has a dedicated constraints file with pins matching the lower bounds defined in setup.py. Furthermore, ensure that the project's metadata in setup.py (specifically python_requires and Trove classifiers) is updated to reflect this change. As dropping support for a Python version is a breaking change, please ensure a minor version bump is used for this release to maintain the ability to provide patches for the previous version.

References
  1. When updating the minimum supported Python version, ensure that the project's metadata in 'setup.py' or 'pyproject.toml' is also updated to reflect the same minimum version in 'python_requires' and Trove classifiers.
  2. When a release introduces breaking changes in environment requirements, such as dropping support for specific Python versions, prefer a minor version bump over a patch version bump.

Comment on lines +541 to +543
script_dir = os.path.dirname(os.path.abspath(__file__))
ignore_file_path = os.path.join(script_dir, ".scannerignore")
ignore_dirs = load_ignore_file(ignore_file_path)
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 code currently only looks for the .scannerignore file in the script's own directory (scripts/version_scanner/). However, the README (line 31) indicates that users should create this file in the directory being scanned (usually the repository root). This inconsistency means that an ignore file placed in the repo root will be ignored by the scanner.

Suggested change
script_dir = os.path.dirname(os.path.abspath(__file__))
ignore_file_path = os.path.join(script_dir, ".scannerignore")
ignore_dirs = load_ignore_file(ignore_file_path)
ignore_dirs = load_ignore_file(os.path.join(args.path, ".scannerignore"))
script_dir = os.path.dirname(os.path.abspath(__file__))
ignore_dirs.extend(load_ignore_file(os.path.join(script_dir, ".scannerignore")))


for root, dirs, files in os.walk(root_path):
# Prune ignore directories (case-insensitive)
dirs[:] = [d for d in dirs if d.lower() not in ignore_lower]
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 current implementation of directory ignoring only checks the base name of each directory against the ignore list. This prevents users from ignoring specific nested paths (e.g., packages/pkg_a/tests). Consider updating the logic to support path-based ignoring or glob patterns to provide more granular control.

Comment on lines +7 to +11
Run the script from the repository root:

```bash
python3 scripts/version_scanner/version_scanner.py -d <dependency> -v <version> [options]
```
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 README provides usage instructions but does not mention the external dependencies required to run the script (e.g., PyYAML, google-auth, google-api-python-client). Adding a section on how to install these dependencies would improve the onboarding experience for other developers.

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