Skip to content

Commit 57d9af2

Browse files
committed
Ignore header difference for osx_framework_user
1 parent 77810bc commit 57d9af2

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/pip/_internal/locations/__init__.py

Lines changed: 14 additions & 0 deletions
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
)
@@ -115,6 +116,19 @@ def get_scheme(
115116
if skip_pypy_special_case:
116117
continue
117118

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

120134
if any(warned):

src/pip/_internal/locations/_sysconfig.py

Lines changed: 3 additions & 7 deletions
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() -> str:
3329
"""Try to find a prefix scheme for the current platform.
3430
@@ -43,7 +39,7 @@ def _infer_prefix() -> str:
4339
4440
If none of the above works, fall back to ``posix_prefix``.
4541
"""
46-
os_framework_global = _is_osx_framework() and not running_under_virtualenv()
42+
os_framework_global = is_osx_framework() and not running_under_virtualenv()
4743
if os_framework_global and "osx_framework_library" in _AVAILABLE_SCHEMES:
4844
return "osx_framework_library"
4945
implementation_suffixed = f"{sys.implementation.name}_{os.name}"
@@ -61,7 +57,7 @@ def _infer_prefix() -> str:
6157

6258
def _infer_user() -> str:
6359
"""Try to find a user scheme for the current platform."""
64-
if _is_osx_framework() and not running_under_virtualenv():
60+
if is_osx_framework() and not running_under_virtualenv():
6561
suffixed = "osx_framework_user"
6662
else:
6763
suffixed = f"{os.name}_user"

src/pip/_internal/locations/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ def get_src_prefix() -> str:
4444
user_site: typing.Optional[str] = site.getusersitepackages()
4545
except AttributeError:
4646
user_site = site.USER_SITE
47+
48+
49+
def is_osx_framework() -> bool:
50+
return bool(sysconfig.get_config_var("PYTHONFRAMEWORK"))

0 commit comments

Comments
 (0)