Skip to content

Commit d4d01b7

Browse files
committed
Ignore header difference for osx_framework_user
1 parent 11c4bcd commit d4d01b7

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/pip/_internal/locations/__init__.py

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
USER_CACHE_DIR,
1212
get_major_minor_version,
1313
get_src_prefix,
14+
is_osx_framework,
1415
site_packages,
1516
user_site,
1617
)
@@ -116,6 +117,18 @@ def get_scheme(
116117
if skip_pypy_special_case:
117118
continue
118119

120+
# sysconfig's ``osx_framework_user`` does not include ``pythonX.Y`` in
121+
# the ``include`` value, but distutils's ``headers`` does. We'll let
122+
# CPython decide whether this is a bug or feature. See bpo-43948.
123+
skip_osx_framework_user_special_case = (
124+
is_osx_framework()
125+
and user
126+
and k == "headers"
127+
and old_v.parent == new_v
128+
)
129+
if skip_osx_framework_user_special_case:
130+
continue
131+
119132
warned.append(_warn_if_mismatch(old_v, new_v, key=f"scheme.{k}"))
120133

121134
if any(warned):

src/pip/_internal/locations/_sysconfig.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pip._internal.models.scheme import SCHEME_KEYS, Scheme
1010
from pip._internal.utils.virtualenv import running_under_virtualenv
1111

12-
from .base import get_major_minor_version
12+
from .base import get_major_minor_version, is_osx_framework
1313

1414
logger = logging.getLogger(__name__)
1515

@@ -25,10 +25,6 @@
2525
_AVAILABLE_SCHEMES = set(sysconfig.get_scheme_names())
2626

2727

28-
def _is_osx_framework() -> bool:
29-
return sysconfig.get_config_var("PYTHONFRAMEWORK")
30-
31-
3228
def _infer_prefix():
3329
# type: () -> str
3430
"""Try to find a prefix scheme for the current platform.
@@ -44,7 +40,7 @@ def _infer_prefix():
4440
4541
If none of the above works, fall back to ``posix_prefix``.
4642
"""
47-
os_framework_global = _is_osx_framework() and not running_under_virtualenv()
43+
os_framework_global = is_osx_framework() and not running_under_virtualenv()
4844
if os_framework_global and "osx_framework_library" in _AVAILABLE_SCHEMES:
4945
return "osx_framework_library"
5046
implementation_suffixed = f"{sys.implementation.name}_{os.name}"
@@ -63,7 +59,7 @@ def _infer_prefix():
6359
def _infer_user():
6460
# type: () -> str
6561
"""Try to find a user scheme for the current platform."""
66-
if _is_osx_framework() and not running_under_virtualenv():
62+
if is_osx_framework() and not running_under_virtualenv():
6763
suffixed = "osx_framework_user"
6864
else:
6965
suffixed = f"{os.name}_user"

src/pip/_internal/locations/base.py

+4
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ def get_src_prefix():
4646
user_site = site.getusersitepackages() # type: typing.Optional[str]
4747
except AttributeError:
4848
user_site = site.USER_SITE
49+
50+
51+
def is_osx_framework() -> bool:
52+
return sysconfig.get_config_var("PYTHONFRAMEWORK")

0 commit comments

Comments
 (0)