1
0

manylinux.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import os
  2. from pathlib import Path
  3. import shutil
  4. from ...appimage import build_appimage
  5. from ...manylinux import ensure_image, PythonExtractor
  6. from ...utils.tmp import TemporaryDirectory
  7. __all__ = ['execute']
  8. def _unpack_args(args):
  9. '''Unpack command line arguments
  10. '''
  11. return args.tag, args.abi
  12. def execute(tag, abi):
  13. '''Build a Python AppImage using a Manylinux image
  14. '''
  15. image = ensure_image(tag)
  16. pwd = os.getcwd()
  17. with TemporaryDirectory() as tmpdir:
  18. python_extractor = PythonExtractor(
  19. arch = image.arch,
  20. prefix = image.path,
  21. tag = abi
  22. )
  23. appdir = Path(tmpdir) / 'AppDir'
  24. python_extractor.extract(appdir, appify=True)
  25. fullname = '-'.join((
  26. f'{python_extractor.impl}{python_extractor.version.long()}',
  27. abi,
  28. f'{image.tag}_{image.arch}'
  29. ))
  30. destination = f'{fullname}.AppImage'
  31. build_appimage(
  32. appdir = str(appdir),
  33. destination = destination
  34. )
  35. shutil.copy(
  36. Path(tmpdir) / destination,
  37. Path(pwd) / destination
  38. )