Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove dependency on deprecated distutils #507

Closed
@noirbee

Description

@noirbee

The distutils module has been deprecated and will be removed in Python3.12: https://docs.python.org/3.11/library/distutils.html

setuptools also discourages using its vendored version: https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html#prefer-setuptools

The explicit distutils dependency / import in abstract_operations_client.py is only needed for one call to distutils.util.strtobool():

util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))

We encountered this under Python3.10 due to the way we build / run our code under Docker. This can be easily circumvented in our case by installing the python3-distutils Debian package, but the dependency should probably be removed from this package.

Environment details

  • OS type and version: Linux 218300304P 6.1.0-9-amd64 [CHANGE ME] Re-generated to pick up changes in the API or client library generator. #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 GNU/Linux
  • Python version: Python 3.12.0b2
  • pip version: pip 23.1.2 from /tmp/venv/lib/python3.12/site-packages/pip (python 3.12)
  • google-api-core version: Name: google-api-core Version: 2.11.0 Summary: Google API client core library Home-page: https://github.com/googleapis/python-api-core Author: Google LLC Author-email: [email protected] License: Apache 2.0 Location: /tmp/venv/lib/python3.12/site-packages Requires: google-auth, googleapis-common-protos, protobuf, requests Required-by:

Steps to reproduce

  1. python3.12 -m venv /tmp/venv
  2. /tmp/venv/bin/pip install google-api-core

Code example

from google.api_core.operations_v1.abstract_operations_client import AbstractOperationsClient

Stack trace

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/venv/lib/python3.12/site-packages/google/api_core/operations_v1/__init__.py", line 17, in <module>
    from google.api_core.operations_v1.abstract_operations_client import AbstractOperationsClient
  File "/tmp/venv/lib/python3.12/site-packages/google/api_core/operations_v1/abstract_operations_client.py", line 17, in <module>
    from distutils import util
ModuleNotFoundError: No module named 'distutils'

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions