mirror of
https://github.com/niess/python-appimage.git
synced 2026-03-14 20:30:13 +01:00
Update the list command
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import os
|
||||
import glob
|
||||
from pathlib import Path
|
||||
|
||||
from ..utils.docker import docker_run
|
||||
from ..manylinux import ensure_image, PythonVersion
|
||||
from ..utils.log import log
|
||||
from ..utils.tmp import TemporaryDirectory
|
||||
|
||||
|
||||
__all__ = ['execute']
|
||||
@@ -18,26 +18,16 @@ def execute(tag):
|
||||
'''List python versions installed in a manylinux image
|
||||
'''
|
||||
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
script = (
|
||||
'for dir in $(ls /opt/python | grep "^cp[0-9]"); do',
|
||||
' version=$(/opt/python/$dir/bin/python -c "import sys; ' \
|
||||
'sys.stdout.write(sys.version.split()[0])")',
|
||||
' echo "$dir $version"',
|
||||
'done',
|
||||
)
|
||||
if tag.startswith('2_'):
|
||||
image = 'manylinux_' + tag
|
||||
else:
|
||||
image = 'manylinux' + tag
|
||||
result = docker_run(
|
||||
'quay.io/pypa/' + image,
|
||||
script,
|
||||
capture = True
|
||||
)
|
||||
pythons = [line.split() for line in result.split(os.linesep) if line]
|
||||
image = ensure_image(tag)
|
||||
|
||||
for (abi, version) in pythons:
|
||||
log('LIST', "{:7} -> /opt/python/{:}".format(version, abi))
|
||||
pythons = []
|
||||
for path in glob.glob(str(image.path / 'opt/python/cp*')):
|
||||
path = Path(path)
|
||||
version = PythonVersion.from_str(path.readlink().name[8:]).long()
|
||||
pythons.append((path.name, version))
|
||||
pythons = sorted(pythons)
|
||||
|
||||
return pythons
|
||||
for (abi, version) in pythons:
|
||||
log('LIST', "{:8} -> /opt/python/{:}".format(version, abi))
|
||||
|
||||
return pythons
|
||||
|
||||
Reference in New Issue
Block a user