Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure-cli feature is broken for Python 3.12 as the distutils module is removed #899

Closed
PeterBosch2 opened this issue Mar 7, 2024 · 4 comments · Fixed by #909
Closed
Labels
bug Something isn't working

Comments

@PeterBosch2
Copy link

How to reproduce?

Setup in a fresh VSCode environment a new DevContainer setup ... e.g., using the wizzard. Select Python on Debian Bookworm, add azure-cli feature. This results in the following devcontainer setup:

{
	"name": "Python 3",
	"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bookworm",
	"features": {
		"ghcr.io/devcontainers/features/azure-cli:1": {}
	}
}

Re-opening VSCode in the container works fine, installation of the feature succeeds. However, the azure-cli does not work at the command line due to the missing distutils package, which is removed in Python 3.12:

vscode ➜ /workspaces/test $ az
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/pipx/venvs/azure-cli/lib/python3.12/site-packages/azure/cli/__main__.py", line 39, in <module>
    az_cli = get_default_cli()
             ^^^^^^^^^^^^^^^^^
  File "/usr/local/pipx/venvs/azure-cli/lib/python3.12/site-packages/azure/cli/core/__init__.py", line 917, in get_default_cli
    from azure.cli.core.azlogging import AzCliLogging
  File "/usr/local/pipx/venvs/azure-cli/lib/python3.12/site-packages/azure/cli/core/azlogging.py", line 30, in <module>
    from azure.cli.core.commands.events import EVENT_INVOKER_PRE_CMD_TBL_TRUNCATE
  File "/usr/local/pipx/venvs/azure-cli/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 25, in <module>
    from azure.cli.core.extension import get_extension
  File "/usr/local/pipx/venvs/azure-cli/lib/python3.12/site-packages/azure/cli/core/extension/__init__.py", line 11, in <module>
    from distutils.sysconfig import get_python_lib  # pylint: disable=deprecated-module
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'distutils'
@PeterBosch2 PeterBosch2 changed the title Azure-cli feature is broken for Python 3.12 as the depreciated distutils module is removed Azure-cli feature is broken for Python 3.12 as the distutils module is removed Mar 7, 2024
@samruddhikhandale
Copy link
Member

Hi 👋

Thanks for reporting this issue, I was able to reproduce as well. Ideally, the Azure CLI team should fix it when one installs az with Python. @PeterBosch2 Can you open an issue, if one doesn't exist already?

However, we can still fix it on our end if we avoid using pip to install az -

  1. Check if az is available in bookworm apt feeds (looks like yes), if yes, then updating https://github.com/devcontainers/features/blob/main/src/azure-cli/install.sh#L21 should fix this issue for amd64

@gauravsaini04 / @prathameshzarkar9 Can you use my suggestion and help fix the issue?

@samruddhikhandale samruddhikhandale added the bug Something isn't working label Mar 8, 2024
@PeterBosch2
Copy link
Author

@samruddhikhandale

@PeterBosch2 Can you open an issue, if one doesn't exist already?

I guess it is known: Azure/azure-cli#27673

There is a statement over there:

We don't guarantee Azure CLI works on all Python versions, such as the latest Python 3.12 or the deprecated Python 3.6. Installing Azure CLI with pip (Azure/azure-cli#20476) is only a supplemental feature we provide for unsupported platforms, but without any warranty.

@gauravsaini04
Copy link
Contributor

Have added the possible fix in pr #909

@gauravsaini04
Copy link
Contributor

PR was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants