@@ -39,56 +39,64 @@ def get_distutils_paths(scheme=None, prefix=None):
39
39
# See https://github.com/mesonbuild/meson/issues/8739.
40
40
# XXX: We should be using sysconfig, but Debian only patches distutils.
41
41
42
- if 'deb_system' in distutils .command .install .INSTALL_SCHEMES :
43
- paths = get_distutils_paths (scheme = 'deb_system' )
44
- install_paths = get_distutils_paths (scheme = 'deb_system' , prefix = '' )
45
- else :
46
- paths = sysconfig .get_paths ()
47
- empty_vars = {'base' : '' , 'platbase' : '' , 'installed_base' : '' }
48
- install_paths = sysconfig .get_paths (vars = empty_vars )
42
+ def get_install_paths ():
43
+ import distutils .command .install
44
+ if 'deb_system' in distutils .command .install .INSTALL_SCHEMES :
45
+ paths = get_distutils_paths (scheme = 'deb_system' )
46
+ install_paths = get_distutils_paths (scheme = 'deb_system' , prefix = '' )
47
+ else :
48
+ paths = sysconfig .get_paths ()
49
+ empty_vars = {'base' : '' , 'platbase' : '' , 'installed_base' : '' }
50
+ install_paths = sysconfig .get_paths (vars = empty_vars )
51
+ return paths , install_paths
49
52
50
53
def links_against_libpython ():
51
54
from distutils .core import Distribution , Extension
52
55
cmd = Distribution ().get_command_obj ('build_ext' )
53
56
cmd .ensure_finalized ()
54
57
return bool (cmd .get_libraries (Extension ('dummy' , [])))
55
58
56
- variables = sysconfig .get_config_vars ()
57
- variables .update ({'base_prefix' : getattr (sys , 'base_prefix' , sys .prefix )})
59
+ def main ():
60
+ variables = sysconfig .get_config_vars ()
61
+ variables .update ({'base_prefix' : getattr (sys , 'base_prefix' , sys .prefix )})
62
+ paths , install_paths = get_install_paths ()
58
63
59
- if sys .version_info < (3 , 0 ):
60
- suffix = variables .get ('SO' )
61
- elif sys .version_info < (3 , 8 , 7 ):
62
- # https://bugs.python.org/issue?@action=redirect&bpo=39825
63
- from distutils .sysconfig import get_config_var
64
- suffix = get_config_var ('EXT_SUFFIX' )
65
- else :
66
- suffix = variables .get ('EXT_SUFFIX' )
64
+ if sys .version_info < (3 , 0 ):
65
+ suffix = variables .get ('SO' )
66
+ elif sys .version_info < (3 , 8 , 7 ):
67
+ # https://bugs.python.org/issue?@action=redirect&bpo=39825
68
+ from distutils .sysconfig import get_config_var
69
+ suffix = get_config_var ('EXT_SUFFIX' )
70
+ else :
71
+ suffix = variables .get ('EXT_SUFFIX' )
67
72
68
- limited_api_suffix = None
69
- if sys .version_info >= (3 , 2 ):
70
- try :
71
- from importlib .machinery import EXTENSION_SUFFIXES
72
- limited_api_suffix = EXTENSION_SUFFIXES [1 ]
73
- except Exception :
74
- pass
73
+ limited_api_suffix = None
74
+ if sys .version_info >= (3 , 2 ):
75
+ try :
76
+ from importlib .machinery import EXTENSION_SUFFIXES
77
+ limited_api_suffix = EXTENSION_SUFFIXES [1 ]
78
+ except Exception :
79
+ pass
75
80
76
- # pypy supports modules targetting the limited api but
77
- # does not use a special suffix to distinguish them:
78
- # https://doc.pypy.org/en/latest/cpython_differences.html#permitted-abi-tags-in-extensions
79
- if '__pypy__' in sys .builtin_module_names :
80
- limited_api_suffix = suffix
81
+ # pypy supports modules targetting the limited api but
82
+ # does not use a special suffix to distinguish them:
83
+ # https://doc.pypy.org/en/latest/cpython_differences.html#permitted-abi-tags-in-extensions
84
+ if '__pypy__' in sys .builtin_module_names :
85
+ limited_api_suffix = suffix
81
86
82
- print (json .dumps ({
83
- 'variables' : variables ,
84
- 'paths' : paths ,
85
- 'sysconfig_paths' : sysconfig .get_paths (),
86
- 'install_paths' : install_paths ,
87
- 'version' : sysconfig .get_python_version (),
88
- 'platform' : sysconfig .get_platform (),
89
- 'is_pypy' : '__pypy__' in sys .builtin_module_names ,
90
- 'is_venv' : sys .prefix != variables ['base_prefix' ],
91
- 'link_libpython' : links_against_libpython (),
92
- 'suffix' : suffix ,
93
- 'limited_api_suffix' : limited_api_suffix ,
94
- }))
87
+ return {
88
+ 'variables' : variables ,
89
+ 'paths' : paths ,
90
+ 'sysconfig_paths' : sysconfig .get_paths (),
91
+ 'install_paths' : install_paths ,
92
+ 'version' : sysconfig .get_python_version (),
93
+ 'platform' : sysconfig .get_platform (),
94
+ 'is_pypy' : '__pypy__' in sys .builtin_module_names ,
95
+ 'is_venv' : sys .prefix != variables ['base_prefix' ],
96
+ 'link_libpython' : links_against_libpython (),
97
+ 'suffix' : suffix ,
98
+ 'limited_api_suffix' : limited_api_suffix ,
99
+ }
100
+
101
+ if __name__ == '__main__' :
102
+ print (json .dumps (main ()))
0 commit comments