-
Notifications
You must be signed in to change notification settings - Fork 3k
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
{Core} Remove deprecated usages of distutils to support Python 3.12 #28796
Conversation
️✔️AzureCLI-FullTest
|
Hi @svenstaro, |
️✔️AzureCLI-BreakingChangeTest
|
Packaging |
Thank you for your contribution svenstaro! We will review the pull request and get back to you soon. |
@microsoft-github-policy-service agree |
7344c1c
to
7ecd62c
Compare
7ecd62c
to
6265ea0
Compare
Reaching out to @svenstaro : The current build on Arch, patched with the diff from this PR, still uses |
@MThomassen: Sorry, fixing right now. |
Should be fixed in Arch. Can we get this patch merged upstream? |
|
In the official CLI package, we always install However, I believe eliminating its usage is the right move. PS: In OS other than macOS, Ref: |
So are we good to merge? What's missing? |
@@ -3,7 +3,7 @@ | |||
# Licensed under the MIT License. See License.txt in the project root for license information. | |||
# -------------------------------------------------------------------------------------------- | |||
|
|||
from distutils.version import StrictVersion # pylint: disable=deprecated-module | |||
from packaging.version import Version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommended in pypa/packaging#520
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core migrated to packaging.version.parse
long ago: #17667.
packaging.version.parse
is the same as packaging.version.Version
: https://github.com/pypa/packaging/blob/bb61b7bcbc429b49e6659a8b6c2966b6ebd046b6/src/packaging/version.py#L47-L56
@@ -22,7 +22,7 @@ | |||
EXTENSIONS_DIR = os.path.expanduser(_CUSTOM_EXT_DIR) if _CUSTOM_EXT_DIR else os.path.join(GLOBAL_CONFIG_DIR, | |||
'cliextensions') | |||
DEV_EXTENSION_SOURCES = _DEV_EXTENSION_SOURCES.split(',') if _DEV_EXTENSION_SOURCES else [] | |||
EXTENSIONS_SYS_DIR = os.path.expanduser(_CUSTOM_EXT_SYS_DIR) if _CUSTOM_EXT_SYS_DIR else os.path.join(get_python_lib(), 'azure-cli-extensions') | |||
EXTENSIONS_SYS_DIR = os.path.expanduser(_CUSTOM_EXT_SYS_DIR) if _CUSTOM_EXT_SYS_DIR else os.path.join(get_path("purelib"), 'azure-cli-extensions') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sample result:
from distutils.sysconfig import get_python_lib
from sysconfig import get_paths
print(get_python_lib())
print(get_paths())
D:\cli\py311\Lib\site-packages
{
'stdlib': 'C:\\Users\\xxx\\AppData\\Local\\Programs\\Python\\Python311\\Lib'
'platstdlib': 'D:\\cli\\py311\\Lib'
'purelib': 'D:\\cli\\py311\\Lib\\site-packages'
'platlib': 'D:\\cli\\py311\\Lib\\site-packages'
'include': 'C:\\Users\\xxx\\AppData\\Local\\Programs\\Python\\Python311\\Include'
'platinclude': 'C:\\Users\\xxx\\AppData\\Local\\Programs\\Python\\Python311\\Include'
'scripts': 'D:\\cli\\py311\\Scripts'
'data': 'D:\\cli\\py311'
}
Also see python/cpython#85454 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between 'purelib' and 'platlib'? Will some extensions exist in platlib only, such as preinstalled extensions in cloudshell? Could you help verify it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #28796 (comment)
@deveshdama Could you please help review the ACS related code? |
@svenstaro, thanks a lot for your contribution. Great work! |
Related command
az --help
Description
Remove
distutils
to support Python 3.12This is related to #27673.
from distutils.sysconfig import get_python_lib
is slow. This PR also saves about 0.2s for each CLI command on Windows.Testing Guide
On Python 3.12, do
az --help
. If it works, this is fixed.This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.