Permalink
Browse files

Merge pull request #3652 from matham/pyinstaller3

Update pyinstaller hooks to use proper api. Fixes #3622.
  • Loading branch information...
akshayaurora committed Sep 25, 2015
2 parents 75aa581 + 775c9b3 commit 988118854806ecefa01c04433f13e80a1b2bd3fd
@@ -8,10 +8,11 @@ package of Kivy.
The package will be either 32 or 64 bits depending on which version of Python
you ran it with.
+-----------------------------------------------------------------------------+
| NOTE: Currently, packages for Windows can be generated with Python 2.7 and |
| Python 3.3+. However, Python 3.3+ support is still experimental |
+-----------------------------------------------------------------------------+
.. note::
Currently, packages for Windows can be generated with Python 2.7 and
Python 3.3+. However, Python 3.3+ support is still experimental, so check
this page for updates in case of issues.
.. _packaging-windows-requirements:
@@ -60,12 +61,20 @@ the main file is named `main.py`.
Open the spec file with your favorite editor and add theses lines at the
beginning of the spec::
from kivy.tools.packaging.pyinstaller_hooks import install_hooks
from kivy.tools.packaging.pyinstaller_hooks import get_hooks
import os
install_hooks(globals())
In the `Analysis()` function, remove the `hookspath=None` parameter.
If you don't do this, the kivy package hook will not be used at all.
In the `Analysis()` function, remove the `hookspath=None` parameter and
the `runtime_hooks` parameter if present. `get_hooks` will return the required
values for both parameters, so at the end of `Analysis()` add `**get_hooks()`.
E.g.::
a = Analysis(['..\\kivy27\\examples\\demo\\touchtracer\\main.py'],
pathex=['g:\\Python\\dev2\\TouchApp'],
hiddenimports=[],
**get_hooks())
This will add the required hooks so that pyinstaller gets the required kivy files.
Then you need to change the `COLLECT()` call to add the data for touchtracer
(`touchtracer.kv`, `particle.png`, ...). Change the line to add a `Tree()`
@@ -125,7 +134,7 @@ If you wish to use Gstreamer, you'll need to further modify the spec file.
correct gstreamer modules, you have to import core.video in the spec file
before doing anything::
from kivy.tools.packaging.pyinstaller_hooks import install_hooks
from kivy.tools.packaging.pyinstaller_hooks import get_hooks
import kivy.core.video
#. You'll need to include the gstreamer directory, found in the kivy distribution,
@@ -151,13 +160,12 @@ From kivy-2.7.bat. Create the VideoPlayer directory alongside kivy-2.7.bat::
Now edit the spec file. At the top of the file add::
import os
from kivy.tools.packaging.pyinstaller_hooks import install_hooks
from kivy.tools.packaging.pyinstaller_hooks import get_hooks
import kivy.core.video
install_hooks(globals())
gst_plugin_path = os.environ.get('GST_PLUGIN_PATH').split('lib')[0]
Remove the `hookspath=None` parameter, and change::
Add `get_hooks` to `Analysis()`, and change::
coll = COLLECT(exe,
a.binaries,
@@ -1,14 +1,15 @@
from os.path import dirname, join
from functools import partial
curdir = dirname(__file__)
def install_hooks(sym, hookspath=None):
def runtime_hooks():
return [join(curdir, 'rt-hook-kivy.py')]
_hookspath = [curdir]
if hookspath is not None:
_hookspath += hookspath
sym['rthooks']['kivy'] = [join(curdir, 'rt-hook-kivy.py')]
sym['Analysis'] = partial(sym['Analysis'], hookspath=_hookspath)
def hookspath():
return [curdir]
def get_hooks():
return {'hookspath': hookspath(), 'runtime_hooks': runtime_hooks()}
@@ -11,19 +11,37 @@
Check kivy documentation about how to use these hook for packaging application.
'''
from os.path import join, basename
from distutils.version import LooseVersion
import PyInstaller
import kivy
from kivy.factory import Factory
try:
pyinst_ver = PyInstaller.get_version() # pyinstaller < 3.0x
except AttributeError:
pyinst_ver = PyInstaller.__version__
def get_modules():
return [x.get('module', None) for x in Factory.classes.values()]
datas = [
(kivy.kivy_data_dir, 'kivy_install'),
(kivy.kivy_modules_dir, 'kivy_install'),
(kivy.kivy_exts_dir, 'kivy_install'),
]
if LooseVersion(pyinst_ver) >= LooseVersion('3.0'):
# in pyinstaller 3, the directory contents rather than the directory itself
# is copied. See https://github.com/pyinstaller/pyinstaller/issues/1513.
datas = [
(kivy.kivy_data_dir,
join('kivy_install', basename(kivy.kivy_data_dir))),
(kivy.kivy_modules_dir,
join('kivy_install', basename(kivy.kivy_modules_dir))),
]
else:
datas = [
(kivy.kivy_data_dir, 'kivy_install'),
(kivy.kivy_modules_dir, 'kivy_install'),
]
# extensions
_kivy_modules = [

0 comments on commit 9881188

Please sign in to comment.