diff --git a/python_appimage/appimage/relocate.py b/python_appimage/appimage/relocate.py index 6923d31..b3bce88 100644 --- a/python_appimage/appimage/relocate.py +++ b/python_appimage/appimage/relocate.py @@ -44,12 +44,12 @@ def patch_binary(path, libdir, recursive=True): excluded = _excluded_libs ensure_patchelf() - rpath = '\'' + system(PATCHELF, '--print-rpath', path) + '\'' + rpath = '\'' + system((PATCHELF, '--print-rpath', path)) + '\'' relpath = os.path.relpath(libdir, os.path.dirname(path)) relpath = '' if relpath == '.' else '/' + relpath expected = '\'$ORIGIN' + relpath + '\'' if rpath != expected: - system(PATCHELF, '--set-rpath', expected, path) + system((PATCHELF, '--set-rpath', expected, path)) deps = ldd(path) for dep in deps: @@ -78,8 +78,8 @@ def relocate_python(python=None, appdir=None): # Set some key variables & paths if python: - FULLVERSION = system(python, '-c', - '"import sys; print(\'{:}.{:}.{:}\'.format(*sys.version_info[:3]))"') + FULLVERSION = system((python, '-c', + '"import sys; print(\'{:}.{:}.{:}\'.format(*sys.version_info[:3]))"')) FULLVERSION = FULLVERSION.strip() else: FULLVERSION = '{:}.{:}.{:}'.format(*sys.version_info[:3]) @@ -92,8 +92,8 @@ def relocate_python(python=None, appdir=None): APPDIR_SHARE = APPDIR + '/usr/share' if python: - HOST_PREFIX = system( - python, '-c', '"import sys; print(sys.prefix)"').strip() + HOST_PREFIX = system(( + python, '-c', '"import sys; print(sys.prefix)"')).strip() else: HOST_PREFIX = sys.prefix HOST_BIN = HOST_PREFIX + '/bin' diff --git a/python_appimage/commands/build/app.py b/python_appimage/commands/build/app.py index 7ad096b..fad7cda 100644 --- a/python_appimage/commands/build/app.py +++ b/python_appimage/commands/build/app.py @@ -132,8 +132,8 @@ def execute(appdir, name=None, python_version=None, linux_tag=None, log('EXTRACT', '%s', os.path.basename(base_image)) urlretrieve(base_image, 'base.AppImage') os.chmod('base.AppImage', stat.S_IRWXU) - system('./base.AppImage --appimage-extract') - system('mv squashfs-root AppDir') + system(('./base.AppImage', '--appimage-extract')) + system(('mv', 'squashfs-root', 'AppDir')) # Bundle the desktop file @@ -212,12 +212,14 @@ def execute(appdir, name=None, python_version=None, linux_tag=None, # Bundle the requirements if requirements_list: - system('./AppDir/AppRun -m pip install -U ' - '--no-warn-script-location pip') + deprecation = 'DEPRECATION: Python 2.7 reached the end of its life' + system(('./AppDir/AppRun', '-m', 'pip', 'install', '-U', + '--no-warn-script-location', 'pip'), exclude=deprecation) for requirement in requirements_list: log('BUNDLE', requirement) - system('./AppDir/AppRun -m pip install -U ' - '--no-warn-script-location ' + requirement) + system(('./AppDir/AppRun', '-m', 'pip', 'install', '-U', + '--no-warn-script-location', requirement), + exclude=deprecation) # Bundle the entry point diff --git a/python_appimage/utils/deps.py b/python_appimage/utils/deps.py index 045361b..a30c0aa 100644 --- a/python_appimage/utils/deps.py +++ b/python_appimage/utils/deps.py @@ -47,7 +47,7 @@ def ensure_appimagetool(): with TemporaryDirectory() as tmpdir: urlretrieve(os.path.join(baseurl, appimage), appimage) os.chmod(appimage, stat.S_IRWXU) - system('./' + appimage, '--appimage-extract') + system(('./' + appimage, '--appimage-extract')) copy_tree('squashfs-root', appdir) if not os.path.exists(APPIMAGETOOL): @@ -87,7 +87,7 @@ def ensure_patchelf(): with TemporaryDirectory() as tmpdir: urlretrieve(os.path.join(baseurl, 'rolling', appimage), appimage) os.chmod(appimage, stat.S_IRWXU) - system('./' + appimage, '--appimage-extract') + system(('./' + appimage, '--appimage-extract')) copy_file('squashfs-root/usr/bin/patchelf', patchelf) os.chmod(patchelf, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) diff --git a/python_appimage/utils/docker.py b/python_appimage/utils/docker.py index 1a79032..c9a0fe7 100644 --- a/python_appimage/utils/docker.py +++ b/python_appimage/utils/docker.py @@ -23,7 +23,7 @@ def docker_run(image, extra_cmds): raise ValueError('Unsupported Docker image: ' + image) log('PULL', image) - system('docker', 'pull', image) + system(('docker', 'pull', image)) script = [ 'set -e', diff --git a/python_appimage/utils/system.py b/python_appimage/utils/system.py index ee471e9..1c82ea0 100644 --- a/python_appimage/utils/system.py +++ b/python_appimage/utils/system.py @@ -9,20 +9,35 @@ from .log import debug __all__ = ['ldd', 'system'] +try: + basestring +except NameError: + basestring = (str, bytes) -def system(*args): + +def system(args, exclude=None): '''System call with capturing output ''' cmd = ' '.join(args) debug('SYSTEM', cmd) + if exclude is None: + exclude = [] + elif isinstance(exclude, basestring): + exclude = [exclude] + else: + exclude = list(exclude) + exclude.append('fuse: warning:') + p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() if err: err = decode(err) - stripped = [line for line in err.split(os.linesep) - if line and not line.startswith('fuse: warning:')] + stripped = [line for line in err.split(os.linesep) if line] + for pattern in exclude: + stripped = [line for line in stripped + if not line.startswith(pattern)] if stripped: raise RuntimeError(err) @@ -35,5 +50,5 @@ _ldd_pattern = re.compile('=> (.+) [(]0x') def ldd(path): '''Get dependencies list of dynamic libraries ''' - out = system('ldd', path) + out = system(('ldd', path)) return _ldd_pattern.findall(out)