diff options
| author | Teddy Wing | 2016-01-24 19:11:43 -0500 |
|---|---|---|
| committer | Teddy Wing | 2016-01-28 14:12:01 -0500 |
| commit | d46230b558c90f9438f07af06d118ef3ecad7f34 (patch) | |
| tree | c2a18a7bd0ddba50ea4c88019a2693227dde341d | |
| parent | 03793287024fbf8af9b8bb7c1c68d62f91406a65 (diff) | |
| download | trufont-integrate-py2app--rb3.tar.bz2 | |
Integrate py2appintegrate-py2app--rb3
Purpose:
--------
This change switches the packaging tool on Mac from PyInstaller to
Py2app in order to take advantage of Py2app's support for ARGV
emulation. This allows us to open files by dragging them onto the
application.
With Adrien's change ac63e80c57b37527f331b209f88d583deeeabcd3, dragging
files onto the application will open files even if the application is
already launched.
To Build:
---------
Run
$ sh Lib/build.sh
This is the same as:
$ python setup.py py2app
Only use py2app if we run the setup file on a Mac. We also have some
pre- and post-build instructions that need to be run, and these are only
executed when on a Mac and the `py2app` argument is passed to `setup.py`
(so they don't get mistakenly run on `python setup.py install`).
If the build script is run on a non-Mac platform, PyInstaller will be
used to build the application bundle as before.
Additional Information
----------------------
* setup.py: Uncommented the `sys` import as I needed it to determine the
current platform and whether we're running `py2app`.
* Globs are used in the Qt framework paths to allow developers/packagers
to use different versions of Qt5. I did this because I'm running OS X
10.8 and couldn't get Qt 5.5 to build on my machine, so I'm using
homebrew/versions/qt52. Homebrew is assumed.
* The `libqsvgicon.dylib` dylib must be added manually or our glyph view
toolbar icons don't get rendered.
* The `libqcocoa.dylib` library must be added or we get this error when
trying to start the application:
This application failed to start because it could not find or load the Qt platform plugin "cocoa".
Reinstalling the application may fix this problem.
Abort trap: 6
* We supply a `qt.conf` file to specify the location of the Qt plugins
directory. This allows us to specify where to find the dylibs we
manually copied into the application bundle.
Info.plist
----------
The Info.plist file generated for the application bundle has been
extended and modified.
* `NSHighResolutionCapable=YES` was kept
* `LSBackgroundOnly=NO` was removed because not setting it turns it off
by default
* Include the `CFBundleIdentifier` copied from `TruFont.spec`
* Set `NSHumanReadableCopyright` to empty string. Otherwise by default
Py2app will insert this key for you whether you like it or not with
the value "Copyright not specified".
* Add the `CFBundleDocumentTypes` key to declare TruFont as an app
capable of opening *.ufo files. This allows us to select TruFont as
the default app to open one or all files of this type using the
"Open with…" functionality throughout OS X.
Known Issues
------------
* The button borders in the glyph view toolbar are wrong. They're square
when they should be invisible with gradiented backgrounds. Not sure
how to correct this.
* This application bundle is about 20 Mb larger than the previous one
generated by PyInstaller. Not sure what's going on there.
| -rw-r--r-- | Lib/build.sh | 6 | ||||
| -rw-r--r-- | qt.conf | 2 | ||||
| -rwxr-xr-x | setup.py | 73 |
3 files changed, 78 insertions, 3 deletions
diff --git a/Lib/build.sh b/Lib/build.sh index 6d03b6a..058d54f 100644 --- a/Lib/build.sh +++ b/Lib/build.sh @@ -1 +1,5 @@ -pyinstaller --onefile TruFont.spec +if [ $(uname) == 'Darwin' ]; then + python setup.py py2app +else + pyinstaller --onefile TruFont.spec +fi @@ -0,0 +1,2 @@ +[Paths] +Plugins = PlugIns @@ -1,6 +1,11 @@ #!/usr/bin/env python -# import sys + +from glob import glob +import os from setuptools import setup +import shutil +from subprocess import call +import sys try: import fontTools # noqa @@ -21,8 +26,48 @@ except: "see:") print(" https://github.com/trufont/defcon") + +name = 'TruFont' +app = [] +options = {} +data_files = [] +setup_requires = [] +build_for_mac = sys.platform == 'darwin' and sys.argv[1] == 'py2app' + +if build_for_mac: + options['py2app'] = { + 'argv_emulation': True, + 'iconfile': 'Lib/defconQt/resources/app.icns', + 'includes': ['sip', 'PyQt5', 'defconQt'], + 'frameworks': [ + glob('/usr/local/Cellar/qt5*/5.*/plugins/platforms/libqcocoa.dylib')[0], + glob('/usr/local/Cellar/qt5*/5.*/plugins/iconengines/libqsvgicon.dylib')[0], + ], + 'qt_plugins': ['*'], + 'plist': { + 'CFBundleIdentifier': 'io.github.trufont', + 'CFBundleDocumentTypes': [ + { + 'CFBundleTypeExtensions': [ + 'ufo', + ], + 'CFBundleTypeName': 'Unified Font Object', + 'CFBundleTypeRole': 'Editor', + 'LSTypeIsPackage': True, + } + ], + 'NSHighResolutionCapable': 'True', + 'NSHumanReadableCopyright': '', + } + } + + app.append('Lib/defconQt/__main__.py') + data_files.append('qt.conf') + setup_requires.append('py2app') + + setup( - name="defconQt", + name=name, version="0.3.0", description="TruFont, a cross-platform font editor. Includes a set of Qt " "objects for working with font data.", @@ -43,6 +88,10 @@ setup( ] }, package_dir={"": "Lib"}, + app=app, + data_files=data_files, + options=options, + setup_requires=setup_requires, platforms=["Linux", "Win32", "Mac OS X"], classifiers=[ "Environment :: GUI", @@ -52,3 +101,23 @@ setup( ], test_suite="tests", ) + + +if build_for_mac: + # Copy dylibs to Qt PlugIns directory + os.makedirs( + 'dist/' + name + '.app/Contents/PlugIns/platforms', + exist_ok=True + ) + os.makedirs( + 'dist/' + name + '.app/Contents/PlugIns/iconengines', + exist_ok=True + ) + shutil.copyfile( + 'dist/' + name + '.app/Contents/Frameworks/libqcocoa.dylib', + 'dist/' + name + '.app/Contents/PlugIns/platforms/libqcocoa.dylib' + ) + shutil.copyfile( + 'dist/' + name + '.app/Contents/Frameworks/libqsvgicon.dylib', + 'dist/' + name + '.app/Contents/PlugIns/iconengines/libqsvgicon.dylib' + ) |
