mirror of https://github.com/pypa/pip
Replace distutils with sysconfig on Python 3.12+
This commit is contained in:
parent
56f8b38e1e
commit
4a014f953d
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
from typing import Optional
|
||||
|
||||
|
@ -203,6 +204,31 @@ def test_build_env_overlay_prefix_has_priority(script: PipTestEnvironment) -> No
|
|||
assert result.stdout.strip() == "2.0", str(result)
|
||||
|
||||
|
||||
if sys.version_info < (3, 12):
|
||||
BUILD_ENV_ERROR_DEBUG_CODE = r"""
|
||||
from distutils.sysconfig import get_python_lib
|
||||
print(
|
||||
f'imported `pkg` from `{pkg.__file__}`',
|
||||
file=sys.stderr)
|
||||
print('system sites:\n ' + '\n '.join(sorted({
|
||||
get_python_lib(plat_specific=0),
|
||||
get_python_lib(plat_specific=1),
|
||||
})), file=sys.stderr)
|
||||
"""
|
||||
else:
|
||||
BUILD_ENV_ERROR_DEBUG_CODE = r"""
|
||||
from sysconfig import get_paths
|
||||
paths = get_paths()
|
||||
print(
|
||||
f'imported `pkg` from `{pkg.__file__}`',
|
||||
file=sys.stderr)
|
||||
print('system sites:\n ' + '\n '.join(sorted({
|
||||
paths['platlib'],
|
||||
paths['purelib'],
|
||||
})), file=sys.stderr)
|
||||
"""
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("enable_user_site")
|
||||
def test_build_env_isolation(script: PipTestEnvironment) -> None:
|
||||
# Create dummy `pkg` wheel.
|
||||
|
@ -231,8 +257,7 @@ def test_build_env_isolation(script: PipTestEnvironment) -> None:
|
|||
run_with_build_env(
|
||||
script,
|
||||
"",
|
||||
r"""
|
||||
from distutils.sysconfig import get_python_lib
|
||||
f"""
|
||||
import sys
|
||||
|
||||
try:
|
||||
|
@ -240,17 +265,9 @@ def test_build_env_isolation(script: PipTestEnvironment) -> None:
|
|||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
print(
|
||||
f'imported `pkg` from `{pkg.__file__}`',
|
||||
file=sys.stderr)
|
||||
print('system sites:\n ' + '\n '.join(sorted({
|
||||
get_python_lib(plat_specific=0),
|
||||
get_python_lib(plat_specific=1),
|
||||
})), file=sys.stderr)
|
||||
print('sys.path:\n ' + '\n '.join(sys.path), file=sys.stderr)
|
||||
{BUILD_ENV_ERROR_DEBUG_CODE}
|
||||
print('sys.path:\\n ' + '\\n '.join(sys.path), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
"""
|
||||
f"""
|
||||
# second check: direct check of exclusion of system site packages
|
||||
import os
|
||||
|
||||
|
|
Loading…
Reference in New Issue