-
Notifications
You must be signed in to change notification settings - Fork 3.1k
pip imports the deprecated distutils module #11103
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
Comments
This module is provided for backward compatibility; on 3.10 it should never be used. So I guess (assuming there's no real bug where we still use it) we simply need to do conditional imports better. |
Maybe only import |
I looked at the code and pip in fact still relies on some distutils internals beside the |
Hi, is there an update on this issue? How can I help? |
No updates (since those would be reflected on this issue). Looking at this now... There's 5 major files that this needs changes for:
Help would be appreciated with all of these. There's one import/use of distutils in a vendored package -- for |
I'll pick up the |
Alrighty, other than the open PRs, the only thing remaining here is moving to a conditional import of the |
distutils.sysconfig import get_python_lib, what should be new import for get_python_lib or what else should be used? |
|
and what for |
https://github.com/python/cpython/blob/main/Lib/sysconfig.py |
This still needs a PR adding a conditional import to |
like this? if _USE_SYSCONFIG:
from . import _distutils |
It'd likely need more changes, but yes -- we basically want to avoid importing distutils if We should also have corresponding tests, to catch us regressing on this FWIW. |
Apparently the problem still reproduces with py311 from deadsnakes on ubuntu while trying to install a package.
Does anyone know a workaround for it as I would really want to enable CI/CD pipeline for py311. I already had success on other projects but on this project, it even fails to install dependencies. |
Unless someone plans to work on this in the coming days, I'm going to push this to down to 22.3. |
I’ll try to find some time this weekend. |
@uranusjr Hmm... does this need anything more than the following? diff --git a/src/pip/_internal/locations/__init__.py b/src/pip/_internal/locations/__init__.py
index 99312d77a..22e90a00f 100644
--- a/src/pip/_internal/locations/__init__.py
+++ b/src/pip/_internal/locations/__init__.py
@@ -11,7 +11,7 @@
from pip._internal.utils.deprecation import deprecated
from pip._internal.utils.virtualenv import running_under_virtualenv
-from . import _distutils, _sysconfig
+from . import _sysconfig
from .base import (
USER_CACHE_DIR,
get_major_minor_version,
@@ -241,6 +241,8 @@ def get_scheme(
if _USE_SYSCONFIG:
return new
+ from . import _distutils
+
old = _distutils.get_scheme(
dist_name,
user=user, |
Maybe not? I am not sure. |
Actully there is one more module we need to fix. |
Description
The
pip/_internal/locations/_distutils.py
file imports the distutils module:pip/src/pip/_internal/locations/_distutils.py
Lines 9 to 12 in cb24fb4
This module is deprecated since Python 3.10 and is going to be removed in Python 3.12: python/cpython#92584 (comment)
Expected behavior
No response
pip version
22.0.4
Python version
3.12.0a0
OS
Linux
How to Reproduce
./python -m venv env
./env/bin/python -m ensurepip -v
Output
Code of Conduct
The text was updated successfully, but these errors were encountered: