1import sys 2 3 4def _pythonlib_compat(): 5 """ 6 On Python 3.7 and earlier, distutils would include the Python 7 library. See pypa/distutils#9. 8 """ 9 from distutils import sysconfig 10 if not sysconfig.get_config_var('Py_ENABLED_SHARED'): 11 return 12 13 yield 'python{}.{}{}'.format( 14 sys.hexversion >> 24, 15 (sys.hexversion >> 16) & 0xff, 16 sysconfig.get_config_var('ABIFLAGS'), 17 ) 18 19 20def compose(f1, f2): 21 return lambda *args, **kwargs: f1(f2(*args, **kwargs)) 22 23 24pythonlib = ( 25 compose(list, _pythonlib_compat) 26 if sys.version_info < (3, 8) 27 and sys.platform != 'darwin' 28 and sys.platform[:3] != 'aix' 29 else list 30) 31