Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

refactor version checks for pandas, pyarrow #769

Description

@tswast

We're using pkg_resources.parse_version from setuptools, which is just a thin wrapper over packaging.

Also, we have some version comparisons for features. I think it'd be cleaner to implement these as properties like we do in BQStorageVersions that I propose adding in #748

importpackaging.version_MIN_BQ_STORAGE_VERSION=packaging.version.Version("2.0.0")
_BQ_STORAGE_OPTIONAL_READ_SESSION_VERSION=packaging.version.Version("2.6.0")
classBQStorageVersions:
def__init__(self):
self._installed_version=None@propertydefinstalled_version(
self,
) ->Union[packaging.version.LegacyVersion, packaging.version.Version]:
ifself._installed_versionisNone:
fromgoogle.cloudimportbigquery_storageself._installed_version=packaging.version.parse(
getattr(bigquery_storage, "__version__", "legacy")
)
returnself._installed_version@propertydefis_read_session_optional(self) ->bool:
returnself.installed_version>=_BQ_STORAGE_OPTIONAL_READ_SESSION_VERSIONdefverify_version(self):
"""Verify that a recent enough version of BigQuery Storage extra is installed. The function assumes that google-cloud-bigquery-storage extra is installed, and should thus be used in places where this assumption holds. Because `pip` can install an outdated version of this extra despite the constraints in setup.py, the the calling code can use this helper to verify the version compatibility at runtime. Raises: LegacyBigQueryStorageError: If google-cloud-bigquery-storage is outdated. """ifself.installed_version<_MIN_BQ_STORAGE_VERSION:
msg= (
"Dependency google-cloud-bigquery-storage is outdated, please upgrade "f"it to version >= 2.0.0 (version found: {self.installed_version})."
)
raiseLegacyBigQueryStorageError(msg)
BQ_STORAGE_VERSIONS=BQStorageVersions()

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the googleapis/python-bigquery API.type: processA process-related concern. May include testing, release, or the like.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions