py37compat.py 671 B

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