New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A number of improvements to the dev environment #291
A number of improvements to the dev environment #291
Conversation
Okay, works awesome on Windows. On OS X, after building:
|
Okay, started by getting rid of the rm ../launch.py, added Plover.dmg to the gitignore. I'll keep playing, but if you know the solution then please enlighten me 👍
|
Oups, sorry about the |
By the way, isn't Mac OS X supported by PyInstaller? |
I'm not familiar with the intricacies of building Python, even more packaging into an image. You are much better with Python than I am, so I'm all ears when you talk. 😁 I've created a gist with my build output and launch crash https://gist.github.com/morinted/2a8568c3e36027e40498 If you have some crazy ideas, I'm willing to try things out. |
Looks like Mac is already using setuptools. Are you available to propose a change that I can test out? |
What if you use PyInstaller instead, with the following spec file in
|
Well, that script didn't work, but just using |
Okay, got around it, how's Also, do you use a PEP8 linter? Noticed /setup.py didn't seem to follow it at all. I'd like to try and use it PEP8 with any new code if possible. If you don't want to make the whitespace change, I can do it while merging. # Copyright (c) 2012 Hesky Fisher
# See LICENSE.txt for details.
"""Platform dependent configuration."""
import pkg_resources
import appdirs
import os
from os.path import realpath, join, dirname, abspath, isfile, pardir
import sys
# If plover is run from a pyinstaller binary.
if hasattr(sys, 'frozen') and hasattr(sys, '_MEIPASS'):
ASSETS_DIR = sys._MEIPASS
PROGRAM_DIR = dirname(sys.executable)
# If plover is run from an app bundle on Mac.
elif (sys.platform.startswith('darwin') and '.app' in realpath(__file__)):
ASSETS_DIR = os.getcwd()
PROGRAM_DIR = abspath(join(dirname(sys.executable), *[pardir] * 3))
else:
PROGRAM_DIR = os.getcwd()
if pkg_resources.resource_isdir('plover', 'assets'):
ASSETS_DIR = pkg_resources.resource_filename('plover', 'assets')
else:
ASSETS_DIR = join(dirname(dirname(realpath(__file__))), 'assets')
# If the program's directory has a plover.cfg file then run in "portable mode",
# i.e. store all data in the same directory. This allows keeping all Plover
# files in a portable drive.
if isfile(join(PROGRAM_DIR, 'plover.cfg')):
CONFIG_DIR = PROGRAM_DIR
else:
CONFIG_DIR = appdirs.user_data_dir('plover', 'plover') |
That version of Can you list the content of the generated plover.app/plover.dmg? Is plover bundled as a zip inside it? Alternatively, you can try PyInstaller support bundling eggs:
Check in |
The one created with the commands you listed above is twice the size (probably because of the egg?) and doesn't start -- gives no visual feedback and system console says "abnormal exit code 255". Attached I used PyInstaller 2.1. I'll try with 3.0 and see if there's a difference. The EDIT: updated wrong second link. |
Regarding the size difference:
Ouch! But the If you still want to make PyInstaller work, I would try without 74a05b5 first. Or keep using py2app and just change # If plover is run from a pyinstaller binary.
if hasattr(sys, 'frozen') and hasattr(sys, '_MEIPASS'):
ASSETS_DIR = sys._MEIPASS
PROGRAM_DIR = dirname(sys.executable)
# If plover is run from an app bundle on Mac.
elif (sys.platform.startswith('darwin') and '.app' in realpath(__file__)):
ASSETS_DIR = os.getcwd()
PROGRAM_DIR = abspath(join(dirname(sys.executable), *[pardir] * 3))
else:
ASSETS_DIR = join(dirname(dirname(realpath(__file__))), 'assets')
PROGRAM_DIR = os.getcwd()
if not sys.platform.startswith('darwin') and \
pkg_resources.resource_isdir('plover', 'assets'):
ASSETS_DIR = pkg_resources.resource_filename('plover', 'assets') |
The stripping is for something very specific:
|
@balshetzer: OK, thanks for the info. @morinted: a better patch for diff --git i/plover/oslayer/config.py w/plover/oslayer/config.py
index 868639b..a4f6c28 100644
--- i/plover/oslayer/config.py
+++ w/plover/oslayer/config.py
@@ -9,20 +9,23 @@ import os
from os.path import realpath, join, dirname, abspath, isfile, pardir
import sys
+bundle_type = None
# If plover is run from a pyinstaller binary.
if hasattr(sys, 'frozen') and hasattr(sys, '_MEIPASS'):
ASSETS_DIR = sys._MEIPASS
PROGRAM_DIR = dirname(sys.executable)
+ bundle_type = 'pyinstaller'
# If plover is run from an app bundle on Mac.
elif (sys.platform.startswith('darwin') and '.app' in realpath(__file__)):
ASSETS_DIR = os.getcwd()
PROGRAM_DIR = abspath(join(dirname(sys.executable), *[pardir] * 3))
+ bundle_type = 'mac'
else:
ASSETS_DIR = join(dirname(dirname(realpath(__file__))), 'assets')
PROGRAM_DIR = os.getcwd()
-if pkg_resources.resource_isdir('plover', 'assets'):
+if bundle_type != 'mac' and pkg_resources.resource_isdir('plover', 'assets'):
ASSETS_DIR = pkg_resources.resource_filename('plover', 'assets')
# If the program's directory has a plover.cfg file then run in "portable mode", This way eggs are still supported when plover is not run from a mac bundle. |
The application class/name is wrong when using
OK? |
Yes sir. You are great.
|
As an aside, PEP8 highlighted unused imports, might want to check that out. I also would appreciate if you were able to port over the meta data like
|
OK, can you see if you can still build the Mac OS X version with those additional changes? Particularly, are Plover assets correctly included? If not, please try uncommenting line 28 in Note: I'll rewrite this branch to squash the fixups when you're okay with the changes so you can merge a clean history. |
Sure! I'm out for another three hours but I'll still get to it tonight.
|
You moved dist up to the root, so I had to use
Got rid of that in
Added Then the resources weren't found. Uncommented that line... Still not found. Seems they are packed in Contents/Resources/assets. Let's change that setup.py line to Hey, it seems to work. Cool. As a note, on OSX it would probably be better to change the name to "Plover" instead of "plover". diff --git a/setup.py b/setup.py
index a2436a5..2ad064d 100755
--- a/setup.py
+++ b/setup.py
@@ -23,11 +23,12 @@ if sys.platform.startswith('darwin'):
options['py2app'] = {
'argv_emulation': True,
'iconfile': 'osx/plover.icns',
- # 'resources': 'plover/assets',
+ 'resources': 'plover/assets/',
}
setuptools.setup(
name = __software_name__,
+ app = ['./launch.py'],
version = __version__,
description = __description__,
long_description = __long_description__,
@@ -44,7 +45,6 @@ setuptools.setup(
install_requires = [
'setuptools',
'pyserial>=2.7',
- 'python-xlib>=0.14',
'appdirs>=1.4.0',
'wxPython>=2.8'
], You will probably want to conditionally add that x11 lib, but otherwise now things are working. Built a .dmg, too. |
OK, made a few more changes:
|
Note: this is disabled when run from a Mac OS X bundle, since it's unsupported by py2app.
All right, this is getting good and close. I think "Plover" should be capitalized; shows lowercase in applications and the menu bar. I'd appreciate the Plover.dmg being built in the dist directory, and then that won't need to be in the .gitignore. Otherwise I like this, thanks for the effort. |
f6ace7c
to
275f520
Compare
OK, done:
|
Looks good, thanks. I think I've hit a rock, though. I was playing with wxPython versions and discovered that wxPython doesn't install on OSX 10.11. I'm trying to work through this, but building isn't working. It's in progress, but for a little I will be MIA for Mac builds. |
A number of improvements to the dev environment
Running on Windows today, I think this broke the building of EXEs. See http://stackoverflow.com/questions/19055089/pyinstaller-onefile-warning-pyconfig-h-when-importing-scipy-or-scipy-signal On launch of the exe, I get an error --> file exists and shouldn't |
To the PyInstaller spec I added: and Now when I run the exe I get
|
Which version? 3.0 or 2.1? Looking into it too... |
Looks like I'm using 2.1. Tried 3.0 -- no good at all (-1 on launch, only 5MB) |
It's the |
OK, so:
I was able to successfully build #!/usr/bin/env python2
import subprocess
import sys
import os
sys.path.insert(0, '..')
from plover import (
__name__ as __software_name__,
__version__,
)
if sys.platform.startswith('win32'):
python = ['python.exe']
pyinstaller = ['pyinstaller.exe']
else:
python = ['python2']
pyinstaller = ['wine', 'pyinstaller.exe']
name = __software_name__.capitalize()
egg = '../dist/%s-%s-py%u.%u.egg' % ((name, __version__) +
sys.version_info[0:2])
print 'creating egg'
subprocess.check_call(python + ['setup.py', '--quiet', 'bdist_egg'], cwd='..')
assert os.path.exists(egg)
print 'running pyinstaller'
subprocess.check_call(pyinstaller + ['--workpath=../build',
'--specpath=../build',
'--distpath=../dist',
'--log-level=WARN',
'--onefile',
'--paths=%s' % egg,
'--name=%s' % name,
'--icon=%s.ico' % name,
'../build/launch.py']) (saved as Can you check if this work for you? If it does I can make a pull request to add it and get rid of |
I had to change your script to be
|
It's normal, I forgot to copy 'launch.py' to 'build/launch.py': this is required, otherwise pyinstaller will automatically add the top directory (containing the original 'launch.py') to the path, and pick up plover from the 'plover' directory instead of the egg. |
Can you copy it manually and test? Meanwhile I'll make a few adjustments and create a pull request. |
So I get that warning
Then Plover starts up as it should. Will you be able to get rid of the open command window that's created when I double click the .exe in Explorer? |
Adding '--windowed' should take care of that. |
Good good... I've got to head out now but I'll be back, likely tomorrow
|
So it works without '--onefile' (with pyinstaller 2.1, branch here], but with it we're hitting another pyinstaller bug (pyinstaller/pyinstaller#782) which results in a annoying warning popup on startup... So let's be pragmatic and go back to not bundling an egg when using pyinstaller: #303 |
application/plover
tolaunch.py
: because I'm lazy and don't like having to setPYTHONPATH
every time I want to work on the Plover source code (this also make it possible to just create a symlink tolaunch.py
in one ofPATH
directories, and run from source)