1
0

list.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import os
  2. from ..utils.docker import docker_run
  3. from ..utils.log import log
  4. from ..utils.tmp import TemporaryDirectory
  5. __all__ = ['execute']
  6. def _unpack_args(args):
  7. '''Unpack command line arguments
  8. '''
  9. return (args.tag,)
  10. def execute(tag):
  11. '''List python versions installed in a manylinux image
  12. '''
  13. with TemporaryDirectory() as tmpdir:
  14. script = (
  15. 'for dir in $(ls /opt/python | grep "^cp[0-9]"); do',
  16. ' version=$(/opt/python/$dir/bin/python -c "import sys; ' \
  17. 'sys.stdout.write(sys.version.split()[0])")',
  18. ' echo "$dir $version"',
  19. 'done',
  20. )
  21. if tag.startswith('2_'):
  22. image = 'manylinux_' + tag
  23. else:
  24. image = 'manylinux' + tag
  25. result = docker_run(
  26. 'quay.io/pypa/' + image,
  27. script,
  28. capture = True
  29. )
  30. pythons = [line.split() for line in result.split(os.linesep) if line]
  31. for (abi, version) in pythons:
  32. log('LIST', "{:7} -> /opt/python/{:}".format(version, abi))
  33. return pythons