Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if python instance was compiled as framework?

Tags:

python

macos

How can one tell if a given instance of Python (on OS X) was compiled with the --enable-framework flag?

The one thing I tried is not entirely conclusive:

% python -c 'import sysconfig, pprint; pprint.pprint(sysconfig.get_config_vars())' | grep -i framework
 'LIBS': '-ldl  -framework CoreFoundation',
 'PYTHONFRAMEWORK': '',
 'PYTHONFRAMEWORKDIR': 'no-framework',
 'PYTHONFRAMEWORKINSTALLDIR': '',
 'PYTHONFRAMEWORKPREFIX': '',
 'RESSRCDIR': 'Mac/Resources/framework',
 'SHLIBS': '-ldl  -framework CoreFoundation',
 'WITH_NEXT_FRAMEWORK': 0,
like image 972
kjo Avatar asked Feb 01 '26 03:02

kjo


1 Answers

The definitive test for an OS X framework build:

./configure --enable-framework ...

is the presence of PYTHONFRAMEWORK in the Python build config variables. This idiom is used throughout the Python standard library:

if get_config_var("PYTHONFRAMEWORK"):
    # framework build

See for example, this test at line 221 in the sysconfig module itself.

like image 189
Ned Deily Avatar answered Feb 02 '26 17:02

Ned Deily