Skip to content
Snippets Groups Projects
Commit 026c2763 authored by Ingo Meyer's avatar Ingo Meyer
Browse files

Added support for group names, hidden apps and automatic graphics switching

parent 3d4e6efd
Branches feature-more_flags
No related tags found
No related merge requests found
shallow-appify
==============
Converts any executable to a non-self-contained mac app bundle which depends on system libraries. Other converters often have problems when complex dependencies (e.g. PyQt) must be included. shallow-appify avoids these problems by referencing present system libraries.
Converts any executable to a non-self-contained mac app bundle which depends on system libraries. Other converters often
have problems when complex dependencies (e.g. PyQt) must be included. shallow-appify avoids these problems by
referencing present system libraries.
Usage
=====
usage: shallow-appify.py [-h] [-d EXECUTABLE_ROOT_PATH] [-i ICON_PATH]
usage: shallow-appify.py [-h] [-d EXECUTABLE_ROOT_PATH]
[-e ENVIRONMENT_VARS [ENVIRONMENT_VARS ...]]
[-o APP_PATH] [-v VERSION_STRING]
[-i ICON_PATH] [-g GROUP] [-n HIDDEN] [-o APP_PATH]
[-v VERSION_STRING] [--conda CONDA_REQ_FILE]
[--conda-channels CONDA_CHANNELS [CONDA_CHANNELS ...]]
[--extension-makefile EXTENSION_MAKEFILE]
executable_path
Creates a runnable application for Mac OS X with references to system
libraries. The result is a NON-self-contained app bundle.
positional arguments:
executable_path Sets the executable that is started when the app is
opened.
......@@ -21,16 +29,35 @@ Usage
-d EXECUTABLE_ROOT_PATH, --executable-directory EXECUTABLE_ROOT_PATH
Defines the executable root directory that will be
included in the app.
-i ICON_PATH, --icon ICON_PATH
Image file that is used for app icon creation. It must
be quadratic with a resolution of 1024x1024 pixels or
more.
-e ENVIRONMENT_VARS [ENVIRONMENT_VARS ...], --environment ENVIRONMENT_VARS [ENVIRONMENT_VARS ...]
Specifies which environment variables -- set on the
current interpreter startup -- shall be included in
the app bundle.
-i ICON_PATH, --icon ICON_PATH
Image file that is used for app icon creation. It must
be quadratic with a resolution of 1024x1024 pixels or
more.
-g GROUP, --group GROUP
Developer group name that is saved to the internal app
plist.
-n HIDDEN, --hidden HIDDEN
Hides the app icon in the dock when given.
-o APP_PATH, --output APP_PATH
Sets the path the app will be saved to.
-v VERSION_STRING, --version VERSION_STRING
Specifies the version string of the program.
--conda CONDA_REQ_FILE
(Python only) Creates a miniconda environment from the
given conda requirements file and includes it in the
app bundle. Can be used to create self-contained
python apps.
--conda-channels CONDA_CHANNELS [CONDA_CHANNELS ...]
(Python only) A list of custom conda channels to
install packages that are not included in the main
anaconda distribution.
--extension-makefile EXTENSION_MAKEFILE
(Python only) Path to a makefile for building python
extension modules. The makefile is called with the
target "app_extension_modules" and a variable
"PYLIBPATH" that holds the path to the conda python
library.
......@@ -66,7 +66,7 @@ INFO_PLIST_TEMPLATE = '''
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
{% if hide_in_dock -%}
{% if hidden -%}
<key>LSUIElement</key>
<string>1</string>
{% endif -%}
......@@ -130,12 +130,16 @@ def parse_args():
parser.add_argument('-d', '--executable-directory', dest='executable_root_path', action='store',
type=os.path.abspath,
help='Defines the executable root directory that will be included in the app.')
parser.add_argument('-i', '--icon', dest='icon_path', action='store', type=os.path.abspath,
help='Image file that is used for app icon creation. It must be quadratic with a '
'resolution of 1024x1024 pixels or more.')
parser.add_argument('-e', '--environment', dest='environment_vars', action='store', nargs='+',
help='Specifies which environment variables -- set on the current interpreter startup -- '
' shall be included in the app bundle.')
parser.add_argument('-i', '--icon', dest='icon_path', action='store', type=os.path.abspath,
help='Image file that is used for app icon creation. It must be quadratic with a '
'resolution of 1024x1024 pixels or more.')
parser.add_argument('-g', '--group', dest='group', action='store',
help='Developer group name that is saved to the internal app plist.')
parser.add_argument('-n', '--hidden', dest='hidden', action='store',
help='Hides the app icon in the dock when given.')
parser.add_argument('-o', '--output', dest='app_path', action='store', type=os.path.abspath,
help='Sets the path the app will be saved to.')
parser.add_argument('-v', '--version', dest='version_string', action='store',
......@@ -183,8 +187,8 @@ def parse_args():
return Arguments(**args)
def create_info_plist_content(app_name, version, executable_path, executable_root_path=None, icon_path=None,
environment_vars=None):
def create_info_plist_content(app_name, version, group, executable_path, executable_root_path=None, icon_path=None,
hidden=False, environment_vars=None):
def get_short_version(version):
match_obj = re.search('\d+(\.\d+){0,2}', version)
if match_obj is not None:
......@@ -206,6 +210,8 @@ def create_info_plist_content(app_name, version, executable_path, executable_roo
vars = {'executable': executable,
'icon_file': os.path.basename(icon_path) if icon_path is not None else None,
'name': app_name,
'group': group,
'hidden': hidden,
'short_version': get_short_version(version),
'version': version}
......@@ -232,8 +238,8 @@ def create_icon_set(icon_path, iconset_out_path):
subprocess.call(('iconutil', '--convert', 'icns', tmp_icns_dir, '--output', iconset_out_path))
def create_app(app_path, version_string, executable_path, executable_root_path=None, icon_path=None,
environment_vars=None, **kwargs):
def create_app(app_path, version_string, group, executable_path, executable_root_path=None, icon_path=None,
hidden=False, environment_vars=None, **kwargs):
def abs_path(relative_bundle_path, base=None):
return os.path.abspath('{app_path}/{dir}'.format(app_path=base or app_path, dir=relative_bundle_path))
......@@ -244,8 +250,8 @@ def create_app(app_path, version_string, executable_path, executable_root_path=N
raise InvalidAppPath('The specified app path is a subpath of the source root directory.')
def write_info_plist():
info_plist_content = create_info_plist_content(app_name, version_string, app_executable_path,
executable_root_path, bundle_icon_path, environment_vars)
info_plist_content = create_info_plist_content(app_name, version_string, group, app_executable_path,
executable_root_path, bundle_icon_path, hidden, environment_vars)
with open(abs_path('Info.plist', contents_path), 'w') as f:
f.writelines(info_plist_content.encode('utf-8'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment