google-cloud-python icon indicating copy to clipboard operation
google-cloud-python copied to clipboard

Add `__version__` to retrieve the library version at runtime in all packages

Open parthea opened this issue 10 months ago • 0 comments

It's possible to query the client library version at runtime using __version__ for most packages, however __version__ is not available in all packages.

As an example, the following works for google-cloud-access-approval

> import google.cloud.accessapproval
> google.cloud.accessapproval.__version__
'1.16.0'

We should add this functionality to the remaining packages along with a unit test.

googleapis-common-protos

> import google.api
> google.api.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'google.api' has no attribute '__version__'

grpc-google-iam-v1

> import google.iam.v1
> google.iam.v1.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'google.iam.v1' has no attribute '__version__'

google-cloud-audit-log

> import google.cloud.audit
> google.cloud.audit.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'google.cloud.audit' has no attribute '__version__'

google-cloud-access-context-manager

> import google.identity.accesscontextmanager.v1
> google.identity.accesscontextmanager.v1.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'google.identity.accesscontextmanager.v1' has no attribute '__version__'

parthea avatar Mar 11 '25 13:03 parthea