Explorar o código

Multiple extra data

Valentin Niess hai 1 ano
pai
achega
03bab9b38d
Modificáronse 2 ficheiros con 18 adicións e 11 borrados
  1. 5 5
      python_appimage/__main__.py
  2. 13 6
      python_appimage/commands/build/app.py

+ 5 - 5
python_appimage/__main__.py

@@ -7,9 +7,9 @@ import sys
 __all__ = ['main']
 
 
-def directory(path):
-    if not os.path.isdir(path):
-        raise argparse.ArgumentTypeError("Not a directory: {}".format(path))
+def exists(path):
+    if not os.path.exists(path):
+        raise argparse.ArgumentTypeError("could not find: {}".format(path))
     return os.path.abspath(path)
 
 def main():
@@ -78,8 +78,8 @@ def main():
                                   help='force pip in-tree-build',
                                   action='store_true',
                                   default=False)
-    build_app_parser.add_argument('-x', '--extra-files', type=directory,
-        help='path to directory containing extra files to be baked in')
+    build_app_parser.add_argument('-x', '--extra-data', type=exists,
+        help='extra application data (bundled under $APPDIR/)', nargs='+')
 
     list_parser = subparsers.add_parser('list',
         description='List Python versions installed in a manylinux image')

+ 13 - 6
python_appimage/commands/build/app.py

@@ -26,14 +26,16 @@ def _unpack_args(args):
     '''Unpack command line arguments
     '''
     return args.appdir, args.name, args.python_version, args.linux_tag,        \
-           args.python_tag, args.base_image, args.in_tree_build, args.extra_files
+           args.python_tag, args.base_image, args.in_tree_build,               \
+           args.extra_data
 
 
 _tag_pattern = re.compile('python([^-]+)[-]([^.]+)[.]AppImage')
 _linux_pattern = re.compile('manylinux([0-9]+)_' + platform.machine())
 
 def execute(appdir, name=None, python_version=None, linux_tag=None,
-            python_tag=None, base_image=None, in_tree_build=False, extra_files=None):
+            python_tag=None, base_image=None, in_tree_build=False,
+            extra_data=None):
     '''Build a Python application using a base AppImage
     '''
 
@@ -287,10 +289,15 @@ def execute(appdir, name=None, python_version=None, linux_tag=None,
                        '--no-warn-script-location', requirement),
                        exclude=(deprecation + git_warnings))
 
-        # Bundle auxilliary application files
-        if extra_files is not None:
-            log('BUNDLE', os.path.basename(extra_files))
-            copy_tree(extra_files, 'AppDir/')
+        # Bundle auxilliary application data
+        if extra_data is not None:
+            for path in extra_data:
+                basename = os.path.basename(path)
+                log('BUNDLE', basename)
+                if os.path.isdir(path):
+                    copy_tree(path, 'AppDir/' + basename)
+                else:
+                    copy_file(path, 'AppDir/')
 
         # Bundle the entry point
         entrypoint_path = glob.glob(appdir + '/entrypoint.*')