Skip to content

Importing azure-devops on Python 3.12 can break other azure packages due to missing import #32365

@remyjette

Description

@remyjette
  • Package Name: all when also used with azure-devops
  • Package Version: any
  • Operating System: Windows 11
  • Python Version: Python 3.12

Describe the bug
The azure-devops has a azure/__init__.py that does an import pkg_resources despite not declaring a dependency on setuptools.
If this is installed, all import azure breaks, even other packages, unless setuptools is also installed independently.

I reported the issue in microsoft/azure-devops-python-api#470 but since that repository doesn't have much activity and the issue is impacting the use of other azure packages I wanted to also post it here.

To Reproduce
Steps to reproduce the behavior:

  1. Install Python 3.12.
  2. Create a venv. On one of my machines it broke even on the main install, but it will definitely break in a venv thanks to Remove bundled setuptools python/cpython#95299
  3. Install azure-devops along with any other azure-sdk-for-python package
  4. Try to import

Expected behavior
Import should succeed

Screenshots

>>> import azure.cosmosdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\rejett\Documents\src\env\Lib\site-packages\azure\__init__.py", line 5, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

Additional context
This might be related to azure-devops still using the legacy 'setup.py install' method microsoft/azure-devops-python-api#441

Metadata

Metadata

Assignees

No one assigned

    Labels

    DevOpscustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions