mirror of
https://github.com/niess/python-appimage.git
synced 2025-07-21 04:41:14 +02:00
Manylinux1 patch
This commit is contained in:
@@ -3,10 +3,11 @@ from types import SimpleNamespace
|
||||
from .config import Arch, LinuxTag, PythonImpl, PythonVersion
|
||||
from .download import Downloader
|
||||
from .extract import ImageExtractor, PythonExtractor
|
||||
from .patch import Patcher
|
||||
|
||||
|
||||
__all__ = ['Arch', 'Downloader', 'ensure_image', 'ImageExtractor', 'LinuxTag',
|
||||
'PythonExtractor', 'PythonImpl', 'PythonVersion']
|
||||
'Patcher', 'PythonExtractor', 'PythonImpl', 'PythonVersion']
|
||||
|
||||
|
||||
def ensure_image(tag, *, clean=False, extract=True):
|
||||
@@ -31,6 +32,9 @@ def ensure_image(tag, *, clean=False, extract=True):
|
||||
)
|
||||
image_extractor.extract(clean=clean)
|
||||
|
||||
patcher = Patcher(tag=tag, arch=arch)
|
||||
patcher.patch(destination = image_extractor.default_destination())
|
||||
|
||||
return SimpleNamespace(
|
||||
arch = arch,
|
||||
tag = tag,
|
||||
|
@@ -247,12 +247,13 @@ class PythonExtractor:
|
||||
raise NotImplementedError()
|
||||
|
||||
# Copy Tcl & Tk data.
|
||||
tcltk_src = self.prefix / 'usr/local/lib'
|
||||
tx_version = []
|
||||
for match in glob.glob(str(tcltk_src / 'tk*')):
|
||||
path = Path(match)
|
||||
if path.is_dir():
|
||||
tx_version.append(LooseVersion(path.name[2:]))
|
||||
for location in ('usr/local/lib', 'usr/share'):
|
||||
tcltk_src = self.prefix / location
|
||||
for match in glob.glob(str(tcltk_src / 'tk*')):
|
||||
path = Path(match)
|
||||
if path.is_dir():
|
||||
tx_version.append(LooseVersion(path.name[2:]))
|
||||
tx_version.sort()
|
||||
tx_version = tx_version[-1]
|
||||
|
||||
|
48
python_appimage/manylinux/patch.py
Normal file
48
python_appimage/manylinux/patch.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
import os
|
||||
import stat
|
||||
import subprocess
|
||||
from typing import Optional
|
||||
|
||||
from .config import Arch, LinuxTag
|
||||
from ..utils.deps import CACHE_DIR
|
||||
from ..utils.log import debug, log
|
||||
from ..utils.url import urlretrieve
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Patcher:
|
||||
'''Manylinux tag.'''
|
||||
tag: LinuxTag
|
||||
|
||||
'''Platform architecture.'''
|
||||
arch: Optional[Arch] = None
|
||||
|
||||
|
||||
def patch(self, destination: Path):
|
||||
'''Apply any patch'''
|
||||
|
||||
cache = Path(CACHE_DIR) / f'share/patches/'
|
||||
|
||||
if self.tag == LinuxTag.MANYLINUX_1:
|
||||
patch = f'tk-manylinux1_{self.arch}'
|
||||
log('PATCH', patch)
|
||||
tarfile = f'{patch}.tar.gz'
|
||||
path = cache / patch
|
||||
if not path.exists():
|
||||
url = f'https://github.com/niess/python-appimage/releases/download/manylinux1/{tarfile}'
|
||||
urlretrieve(url, path)
|
||||
mode = os.stat(path)[stat.ST_MODE]
|
||||
os.chmod(path, mode | stat.S_IWGRP | stat.S_IWOTH)
|
||||
|
||||
debug('EXTRACT', tarfile)
|
||||
cmd = ''.join((
|
||||
f'trap \'chmod u+rw -R {destination}\' EXIT ; ',
|
||||
f'mkdir -p {destination} && ',
|
||||
f'tar -xzf {tarfile} -C {destination}',
|
||||
))
|
||||
r = subprocess.run(f'/bin/bash -c "{cmd}"', shell=True,
|
||||
capture_output=True)
|
||||
if r.returncode != 0:
|
||||
raise ValueError(r.stderr.decode())
|
Reference in New Issue
Block a user