diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index 047f709..ac75e4f 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -26,7 +26,7 @@ jobs: - name: Build run: | # Build the AppImage - python -m python_appimage manylinux \ + python -m python_appimage build manylinux \ ${{ matrix.image }}_${{ matrix.arch }} \ ${{ matrix.tag }} @@ -43,6 +43,7 @@ jobs: echo "::set-env name=PYTHON_VERSION::${version}" - uses: actions/upload-artifact@v1 + if: github.ref == 'refs/heads/master' with: name: python${{ env.PYTHON_VERSION }}-appimages path: ${{ env.PYTHON_APPIMAGE }} @@ -50,6 +51,7 @@ jobs: Release: needs: Build runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' strategy: matrix: version: [2.7, 3.5, 3.6, 3.7, 3.8] diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 9b20c18..5609052 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -23,12 +23,14 @@ jobs: - name: Test local builder run: | - python -m python_appimage local -p $(which python) -d test.AppImage + python -m python_appimage build local -p $(which python) \ + -d test.AppImage test -e test.AppImage Publish: needs: Test runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 2db725d..fb62e61 100644 --- a/.gitignore +++ b/.gitignore @@ -3,9 +3,10 @@ *.pyo __pycache__ AppDir -build +build/* dist python_appimage.egg-info python_appimage/bin python_appimage/data/excludelist python_appimage/version.py +!python_appimage/commands/build diff --git a/python_appimage/__main__.py b/python_appimage/__main__.py index 6e11fec..9b2340c 100644 --- a/python_appimage/__main__.py +++ b/python_appimage/__main__.py @@ -15,13 +15,12 @@ def main(): # Binary dependencies binaries = ('appimagetool', 'patchelf') - # Parse arguments parser = argparse.ArgumentParser( prog='python-appimage', description='Bundle a Python installation into an AppImage') subparsers = parser.add_subparsers(title='command', - help='Build or install command', + help='Command to execute', dest='command') parser.add_argument('-q', '--quiet', help='disable logging', @@ -34,21 +33,28 @@ def main(): install_parser.add_argument('binary', nargs='+', choices=binaries, help='one or more binary name') - local_parser = subparsers.add_parser('local', - description='Bundle a local Python installation') - local_parser.add_argument('-d', '--destination', - help='AppImage destination') - local_parser.add_argument('-p', '--python', help='python executable') + build_parser = subparsers.add_parser('build', + description='Build a Python appimage') + build_subparsers = build_parser.add_subparsers( + title='type', + help='Type of AppImage build', + dest='sub_command') - manylinux_parser = subparsers.add_parser('manylinux', + build_local_parser = build_subparsers.add_parser('local', + description='Bundle a local Python installation') + build_local_parser.add_argument('-d', '--destination', + help='AppImage destination') + build_local_parser.add_argument('-p', '--python', help='python executable') + + build_manylinux_parser = build_subparsers.add_parser('manylinux', description='Bundle a manylinux Python installation using docker') - manylinux_parser.add_argument('tag', + build_manylinux_parser.add_argument('tag', help='manylinux image tag (e.g. 2010_x86_64)') - manylinux_parser.add_argument('abi', + build_manylinux_parser.add_argument('abi', help='python ABI (e.g. cp37-cp37m)') - manylinux_parser.add_argument('--contained', help=argparse.SUPPRESS, - action='store_true', default=False) + build_manylinux_parser.add_argument('--contained', help=argparse.SUPPRESS, + action='store_true', default=False) which_parser = subparsers.add_parser('which', description='Locate a binary dependency') @@ -62,8 +68,10 @@ def main(): logging.getLogger().setLevel(args.verbosity) # Call the requested command - command = import_module('.commands.' + - args.command, package=__package__) + module = '.commands.' + args.command + if args.sub_command: + module += '.' + args.sub_command + command = import_module(module, package=__package__) command.execute(*command._unpack_args(args)) diff --git a/python_appimage/commands/build/__init__.py b/python_appimage/commands/build/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python_appimage/commands/local.py b/python_appimage/commands/build/local.py similarity index 90% rename from python_appimage/commands/local.py rename to python_appimage/commands/build/local.py index 04a07c2..25eef08 100644 --- a/python_appimage/commands/local.py +++ b/python_appimage/commands/build/local.py @@ -2,8 +2,8 @@ import glob import os import shutil -from ..appimage import build_appimage, relocate_python -from ..utils.tmp import TemporaryDirectory +from ...appimage import build_appimage, relocate_python +from ...utils.tmp import TemporaryDirectory __all__ = ['execute'] diff --git a/python_appimage/commands/manylinux.py b/python_appimage/commands/build/manylinux.py similarity index 94% rename from python_appimage/commands/manylinux.py rename to python_appimage/commands/build/manylinux.py index f9bd4d6..e4c72d2 100644 --- a/python_appimage/commands/manylinux.py +++ b/python_appimage/commands/build/manylinux.py @@ -4,10 +4,10 @@ import platform import shutil import sys -from ..appimage import build_appimage, relocate_python -from ..utils.docker import docker_run -from ..utils.fs import copy_tree -from ..utils.tmp import TemporaryDirectory +from ...appimage import build_appimage, relocate_python +from ...utils.docker import docker_run +from ...utils.fs import copy_tree +from ...utils.tmp import TemporaryDirectory __all__ = ['execute'] @@ -41,7 +41,7 @@ def execute(tag, abi, contained=False): python = '/opt/python/' + abi + '/bin/python' pwd = os.getcwd() - dirname = os.path.abspath(os.path.dirname(__file__) + '/..') + dirname = os.path.abspath(os.path.dirname(__file__) + '/../..') with TemporaryDirectory() as tmpdir: copy_tree(dirname, 'python_appimage')