Skip to content

feat(core): add runtime Python version support warning for EoL versions - #997

Closed
lahirumaramba wants to merge 1 commit into
firebase:mainfrom
lahirumaramba:feat/python-version-support-warning
Closed

lahirumaramba wants to merge 1 commit into
firebase:mainfrom
lahirumaramba:feat/python-version-support-warning

Conversation

@lahirumaramba

@lahirumaramba lahirumaramba commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements the policy to drop End-of-Life (EoL) Python versions in minor releases, aligning firebase-admin with Google Cloud Python client libraries and google-api-core.

Adds firebase_admin/_python_version_support.py (adapted from google.api_core._python_version_support at 1ca1428 and f442d1f) and invokes check_python_version(package="firebase-admin") once at package import time in firebase_admin/__init__.py.

Key Changes

  • Runtime Python Version Support Check (firebase_admin/_python_version_support.py):
  • Matches google-api-core lifecycle defaults (gapic_deprecation = python_eol - 1 year, gapic_end = python_eol + 1 week) with no custom grace overrides.
  • Includes an explicit VersionInfo entry for Python 3.9 (PSF EoL 2025-10-05) alongside Python 3.10–3.14 so that the warning recommends upgrading to at least Python 3.11. With default gapic_end, both Python 3.9 and 3.10 (both past EoL) emit the PYTHON_VERSION_UNSUPPORTED FutureWarning ("You are using a non-supported Python version... upgrade to at least Python 3.11"), matching the upcoming removal of both 3.9 and 3.10 in the next minor release.
  • Emits FutureWarning (rather than DeprecationWarning, which Python hides by default outside __main__) so developers see the warning in logs when importing firebase_admin.
  • Invoked once at package import time in firebase_admin/__init__.py (_python_version_support.check_python_version(package="firebase-admin")), consistent with google.api_core.__init__.
  • Safeguards importlib.metadata.packages_distributions() using getattr(metadata, "packages_distributions", None) for Python 3.9 compatibility and only resolves the package label lazily when a warning is emitted.
  • Documentation (README.md):
  • Updates the Supported Python Versions section to note that Python 3.9 and 3.10 support is deprecated and will be dropped in an upcoming minor release, and recommends Python 3.11 or higher.
  • Unit Tests (tests/test_python_version_support.py):
  • Adds 50 date-injected unit tests (today= parameter) covering Python 3.9, 3.10, supported versions (3.11–3.14), untracked older (3.8) and future (3.15, 40.0) versions, and gapic_deprecation / gapic_end overrides.

Proposed Release Note

Python 3.9 and 3.10 are deprecated (both past EOL). Importing firebase_admin on these versions now emits a FutureWarning. Support for both will be dropped in the next minor release; please upgrade to Python 3.11 or higher.

Testing

  • pytest tests/test_python_version_support.py tests/test_app.py (154 passed)
  • pylint firebase_admin/__init__.py firebase_admin/_python_version_support.py tests/test_python_version_support.py (10.00/10)

Add _python_version_support module (adapted from google-api-core) and invoke check_python_version(package='firebase-admin') at package import time to emit a FutureWarning on deprecated and End-of-Life Python versions (<= 3.10).
@lahirumaramba
lahirumaramba requested a review from a team October 20, 2026 18:09

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

Copy link
Copy Markdown

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 introduces a Python version support check mechanism for the Firebase Admin Python SDK, deprecating support for Python 3.9 and 3.10. It adds a new _python_version_support module to check the running Python version against predefined EOL dates, integrates this check into the package initialization, and includes comprehensive unit tests. The review feedback highlights a logical bug in the EOL warning date calculation that limits the warning to a single day, an incorrect package name string passed to the version check that bypasses distribution mapping, and the corresponding test updates needed to reflect the corrected EOL logic.

warnings.warn(message, FutureWarning)
return PythonVersionStatus.PYTHON_VERSION_UNSUPPORTED

eol_date = version_info.python_eol + EOL_GRACE_PERIOD

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

eol_date is currently calculated as version_info.python_eol + EOL_GRACE_PERIOD. Since gapic_end also defaults to version_info.python_eol + EOL_GRACE_PERIOD, this means eol_date and gapic_end are identical by default. As a result, the PYTHON_VERSION_EOL warning is only active for exactly one day. For any day between python_eol and gapic_end - 1 day (the grace period), the code falls back to returning PYTHON_VERSION_DEPRECATED. This causes the deprecation warning to be shown after the Python version has already reached its EOL, resulting in a confusing message that says "once it reaches its end of life ({version_info.python_eol})" even though that date is in the past. Changing eol_date to version_info.python_eol ensures that the EOL warning is correctly shown starting from the actual EOL date up to gapic_end.

Suggested change
eol_date = version_info.python_eol + EOL_GRACE_PERIOD
eol_date = version_info.python_eol



# Perform Python version check and emit a support warning if needed.
_python_version_support.check_python_version(package='firebase-admin')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The package name passed to check_python_version is 'firebase-admin'. However, the automatic package distribution mapping in _get_distribution_and_import_packages expects the importable module name (which is 'firebase_admin') to resolve it to the PyPI distribution name. By passing 'firebase-admin' directly, the mapping logic is bypassed because 'firebase-admin' is not a key in packages_distributions(). Passing 'firebase_admin' instead will allow the mapping to succeed and produce a more informative warning message like package firebase-admin (firebase_admin).

Suggested change
_python_version_support.check_python_version(package='firebase-admin')
_python_version_support.check_python_version(package='firebase_admin')

Comment on lines +84 to +113
test_cases = {
'supported_before_deprecation_date': {
'date': gapic_dep - datetime.timedelta(days=1),
'expected': PythonVersionStatus.PYTHON_VERSION_SUPPORTED,
},
'deprecated_on_deprecation_date': {
'date': gapic_dep,
'expected': PythonVersionStatus.PYTHON_VERSION_DEPRECATED,
},
'deprecated_on_eol_date': {
'date': version_info.python_eol,
'expected': PythonVersionStatus.PYTHON_VERSION_DEPRECATED,
},
'deprecated_before_eol_warning_starts': {
'date': eol_warning_starts - datetime.timedelta(days=1),
'expected': PythonVersionStatus.PYTHON_VERSION_DEPRECATED,
},
'eol_on_eol_warning_date': {
'date': eol_warning_starts,
'expected': PythonVersionStatus.PYTHON_VERSION_EOL,
},
'eol_on_gapic_end_date': {
'date': gapic_end,
'expected': PythonVersionStatus.PYTHON_VERSION_EOL,
},
'unsupported_after_gapic_end_date': {
'date': gapic_end + datetime.timedelta(days=1),
'expected': PythonVersionStatus.PYTHON_VERSION_UNSUPPORTED,
},
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since we are changing eol_date to version_info.python_eol, the test cases in get_tracked_version_test_cases need to be updated to reflect that the EOL warning starts on the actual EOL date rather than after the grace period.

        test_cases = {
            'supported_before_deprecation_date': {
                'date': gapic_dep - datetime.timedelta(days=1),
                'expected': PythonVersionStatus.PYTHON_VERSION_SUPPORTED,
            },
            'deprecated_on_deprecation_date': {
                'date': gapic_dep,
                'expected': PythonVersionStatus.PYTHON_VERSION_DEPRECATED,
            },
            'deprecated_before_eol_date': {
                'date': version_info.python_eol - datetime.timedelta(days=1),
                'expected': PythonVersionStatus.PYTHON_VERSION_DEPRECATED,
            },
            'eol_on_eol_date': {
                'date': version_info.python_eol,
                'expected': PythonVersionStatus.PYTHON_VERSION_EOL,
            },
            'eol_on_gapic_end_date': {
                'date': gapic_end,
                'expected': PythonVersionStatus.PYTHON_VERSION_EOL,
            },
            'unsupported_after_gapic_end_date': {
                'date': gapic_end + datetime.timedelta(days=1),
                'expected': PythonVersionStatus.PYTHON_VERSION_UNSUPPORTED,
            },
        }

@lahirumaramba lahirumaramba added the release:stage Stage a release candidate label Oct 20, 2026
@lahirumaramba

Copy link
Copy Markdown
Member Author

Superseded by #998

@lahirumaramba
lahirumaramba deleted the feat/python-version-support-warning branch October 21, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:stage Stage a release candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant