11import logging
22import pathlib
3- import sys
43import sysconfig
54from typing import List , Optional
65
7- from pip ._internal .models .scheme import SCHEME_KEYS , Scheme
6+ from pip ._internal .models .scheme import Scheme
87
98from . import _distutils , _sysconfig
109from .base import (
@@ -85,51 +84,12 @@ def get_scheme(
8584 isolated = isolated ,
8685 prefix = prefix ,
8786 )
88- new = _sysconfig .get_scheme (
89- dist_name ,
90- user = user ,
91- home = home ,
92- root = root ,
93- isolated = isolated ,
94- prefix = prefix ,
95- )
96-
97- base = prefix or home or _default_base (user = user )
98- warned = []
99- for k in SCHEME_KEYS :
100- # Extra join because distutils can return relative paths.
101- old_v = pathlib .Path (base , getattr (old , k ))
102- new_v = pathlib .Path (getattr (new , k ))
103-
104- # distutils incorrectly put PyPy packages under ``site-packages/python``
105- # in the ``posix_home`` scheme, but PyPy devs said they expect the
106- # directory name to be ``pypy`` instead. So we treat this as a bug fix
107- # and not warn about it. See bpo-43307 and python/cpython#24628.
108- skip_pypy_special_case = (
109- sys .implementation .name == "pypy"
110- and home is not None
111- and k in ("platlib" , "purelib" )
112- and old_v .parent == new_v .parent
113- and old_v .name == "python"
114- and new_v .name == "pypy"
115- )
116- if skip_pypy_special_case :
117- continue
118-
119- warned .append (_warn_if_mismatch (old_v , new_v , key = f"scheme.{ k } " ))
120-
121- if any (warned ):
122- _log_context (user = user , home = home , root = root , prefix = prefix )
123-
12487 return old
12588
12689
12790def get_bin_prefix ():
12891 # type: () -> str
12992 old = _distutils .get_bin_prefix ()
130- new = _sysconfig .get_bin_prefix ()
131- if _warn_if_mismatch (pathlib .Path (old ), pathlib .Path (new ), key = "bin_prefix" ):
132- _log_context ()
13393 return old
13494
13595
@@ -142,43 +102,20 @@ def get_purelib():
142102 # type: () -> str
143103 """Return the default pure-Python lib location."""
144104 old = _distutils .get_purelib ()
145- new = _sysconfig .get_purelib ()
146- if _warn_if_mismatch (pathlib .Path (old ), pathlib .Path (new ), key = "purelib" ):
147- _log_context ()
148105 return old
149106
150107
151108def get_platlib ():
152109 # type: () -> str
153110 """Return the default platform-shared lib location."""
154111 old = _distutils .get_platlib ()
155- new = _sysconfig .get_platlib ()
156- if _warn_if_mismatch (pathlib .Path (old ), pathlib .Path (new ), key = "platlib" ):
157- _log_context ()
158112 return old
159113
160114
161115def get_prefixed_libs (prefix ):
162116 # type: (str) -> List[str]
163117 """Return the lib locations under ``prefix``."""
164118 old_pure , old_plat = _distutils .get_prefixed_libs (prefix )
165- new_pure , new_plat = _sysconfig .get_prefixed_libs (prefix )
166-
167- warned = [
168- _warn_if_mismatch (
169- pathlib .Path (old_pure ),
170- pathlib .Path (new_pure ),
171- key = "prefixed-purelib" ,
172- ),
173- _warn_if_mismatch (
174- pathlib .Path (old_plat ),
175- pathlib .Path (new_plat ),
176- key = "prefixed-platlib" ,
177- ),
178- ]
179- if any (warned ):
180- _log_context (prefix = prefix )
181-
182119 if old_pure == old_plat :
183120 return [old_pure ]
184121 return [old_pure , old_plat ]
0 commit comments