blob: cffa27cb08285d1535e9812858dbad1551fc972f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
"""
Backward compatibility for homebrew builds on macOS.
"""
import sys
import os
import functools
import subprocess
import sysconfig
@functools.lru_cache()
def enabled():
"""
Only enabled for Python 3.9 framework homebrew builds
except ensurepip and venv.
"""
PY39 = (3, 9) < sys.version_info < (3, 10)
framework = sys.platform == 'darwin' and sys._framework
homebrew = "Cellar" in sysconfig.get_config_var('projectbase')
venv = sys.prefix != sys.base_prefix
ensurepip = os.environ.get("ENSUREPIP_OPTIONS")
return PY39 and framework and homebrew and not venv and not ensurepip
schemes = dict(
osx_framework_library=dict(
stdlib='{installed_base}/{platlibdir}/python{py_version_short}',
platstdlib='{platbase}/{platlibdir}/python{py_version_short}',
purelib='{homebrew_prefix}/lib/python{py_version_short}/site-packages',
platlib='{homebrew_prefix}/{platlibdir}/python{py_version_short}/site-packages',
include='{installed_base}/include/python{py_version_short}{abiflags}',
platinclude='{installed_platbase}/include/python{py_version_short}{abiflags}',
scripts='{homebrew_prefix}/bin',
data='{homebrew_prefix}',
)
)
@functools.lru_cache()
def vars():
if not enabled():
return {}
homebrew_prefix = subprocess.check_output(['brew', '--prefix'], text=True).strip()
return locals()
def scheme(name):
"""
Override the selected scheme for posix_prefix.
"""
if not enabled() or not name.endswith('_prefix'):
return name
return 'osx_framework_library'
|