Skip to content

{Extension}: drop distutils.sysconfig, deprecated#20391

Closed
bluca wants to merge 1 commit into
Azure:devfrom
bluca:distutils
Closed

{Extension}: drop distutils.sysconfig, deprecated#20391
bluca wants to merge 1 commit into
Azure:devfrom
bluca:distutils

Conversation

@bluca

@bluca bluca commented Nov 17, 2021

Copy link
Copy Markdown
Member

Python is breaking backward compatibility by removing distutils.sysconfig
without providing an alternative. For now, hard-code the dist-packages
path until they provide a different solution.

Python is breaking backward compatibility by removing distutils.sysconfig
without providing an alternative. For now, hard-code the dist-packages
path until they provide a different solution.
@yonzhan

yonzhan commented Nov 17, 2021

Copy link
Copy Markdown
Collaborator

Extension

@jiasli

jiasli commented Nov 18, 2021

Copy link
Copy Markdown
Contributor

The PR looks good to me.

Python is breaking backward compatibility

I think Python does provide an alternative sysconfig.get_path. It is just that Debian hasn't released their customized Python 3.10 with sysconfig.get_path patched for dist-packages.

Here is the output from official Python docker image (which is also built on Debian):

> docker run -it --rm python:3.10
Python 3.10.0 (default, Nov 17 2021, 15:26:39) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import distutils.sysconfig
<stdin>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<stdin>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
>>> import sysconfig
>>> distutils.sysconfig.get_python_lib()
'/usr/local/lib/python3.10/site-packages'
>>> sysconfig.get_path('purelib')
'/usr/local/lib/python3.10/site-packages'

The results of distutils.sysconfig.get_python_lib() and sysconfig.get_path('purelib') are the same.

Comment thread src/azure-cli-core/azure/cli/core/extension/__init__.py
@jiasli

jiasli commented Nov 18, 2021

Copy link
Copy Markdown
Contributor

Wait. Hard-coding it will break #12856 which depends on distutils.sysconfig.get_python_lib().

The only solution I can think of is for Debian to support their customized sysconfig.get_path.

@bluca

bluca commented Nov 23, 2021

Copy link
Copy Markdown
Member Author

Wait. Hard-coding it will break #12856 which depends on distutils.sysconfig.get_python_lib().

The only solution I can think of is for Debian to support their customized sysconfig.get_path.

ok, closing for now

@bluca bluca closed this Nov 23, 2021
@bebound

bebound commented Nov 22, 2023

Copy link
Copy Markdown
Contributor

Wait. Hard-coding it will break #12856 which depends on distutils.sysconfig.get_python_lib().

The only solution I can think of is for Debian to support their customized sysconfig.get_path.

distutils is dropped in 3.12, we need to reconsider this.

AFAIS, sysconfig.get_path works well.

@jiasli

jiasli commented Jul 25, 2024

Copy link
Copy Markdown
Contributor

With the official Azure CLI MSI package, distutils.sysconfig.get_python_lib() on Windows returns C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages:

> & "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe" -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())"
C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages

With the official Azure CLI ZIP package, distutils.sysconfig.get_python_lib() returns something like D:\tools\azure-cli\Lib\site-packages:

> D:\tools\azure-cli\python.exe -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())"
D:\tools\azure-cli\Lib\site-packages

With the official Azure CLI DEB package, distutils.sysconfig.get_python_lib() on Ubuntu/Debian returns /opt/az/lib/python3.11/site-packages.

$ /opt/az/bin/python3 -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())"
/opt/az/lib/python3.11/site-packages

Hard-coding it to /usr/lib/python3/dist-packages breaks all Azure CLI packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants