Table Of Contents
Pyinstaller hooks¶
Module that exports pyinstaller related methods and parameters.
Hooks¶
PyInstaller comes with a default hook for kivy that lists the indirectly
imported modules that pyinstaller would not find on its own using
get_deps_all()
. hookspath()
returns the path to an alternate kivy
hook, kivy/tools/packaging/pyinstaller_hooks/kivy-hook.py
that does not
add these dependencies to its list of hidden imports and they have to be
explicitly included instead.
One can overwrite the default hook by providing on the command line the
--additional-hooks-dir=HOOKSPATH
option. Because although the default
hook will still run, the important global variables, e.g.
excludedimports
and hiddenimports
will be overwritten by the
new hook, if set there.
Additionally, one can add a hook to be run after the default hook by
passing e.g. hookspath=[HOOKSPATH]
to the Analysis
class. In both
cases, HOOKSPATH
is the path to a directory containing a file named
hook-kivy.py
that is the pyinstaller hook for kivy to be processed
after the default hook.
Hook generator¶
pyinstaller_hooks
includes a tool to generate a hook which lists
all the provider modules in a list so that one can manually comment out
the providers not to be included. To use, do:
python -m kivy.tools.packaging.pyinstaller_hooks hook filename
filename
is the name and path of the hook file to create. If filename
is not provided the hook is printed to the terminal.
-
kivy.tools.packaging.pyinstaller_hooks.
add_dep_paths
()[ソース]¶ Should be called by the hook. It adds the paths with the binary dependencies to the system path so that pyinstaller can find the binaries during its crawling stage.
-
kivy.tools.packaging.pyinstaller_hooks.
get_deps_all
()[ソース]¶ Similar to
get_deps_minimal()
, but this returns all the kivy modules that can indirectly imported. Which includes all the possible kivy providers.This can be used to get a list of all the possible providers which can then manually be included/excluded by commenting out elements in the list instead of passing on all the items. See module description.
戻り値: A dict with two keys, hiddenimports
andexcludes
. Their values are a list of the corresponding modules to include/exclude. This can be passed directly to Analysis` with e.g.a = Analysis(['..\kivy\examples\demo\touchtracer\main.py'], ... **get_deps_all())
-
kivy.tools.packaging.pyinstaller_hooks.
get_deps_minimal
(exclude_ignored=True, **kwargs)[ソース]¶ Returns Kivy hidden modules as well as excluded modules to be used with
Analysis
.The function takes core modules as keyword arguments and their value indicates which of the providers to include/exclude from the compiled app.
The possible keyword names are
audio, camera, clipboard, image, spelling, text, video, and window
. Their values can be:True
: Include current provider- The providers imported when the core module is loaded on this system are added to hidden imports. This is the default if the keyword name is not specified.
None
: Exclude- Don’t return this core module at all.
A string or list of strings
: Providers to include- Each string is the name of a provider for this module to be included.
For example,
get_deps_minimal(video=None, window=True, audio=['gstplayer', 'ffpyplayer'], spelling='enchant')
will exclude all the video providers, will include the gstreamer and ffpyplayer providers for audio, will include the enchant provider for spelling, and will use the current default provider forwindow
.exclude_ignored
, ifTrue
(the default), if the value for a core library isNone
, then ifexclude_ignored
is True, not only will the library not be included in the hiddenimports but it’ll also added to the excluded imports to prevent it being included accidentally by pyinstaller.戻り値: A dict with two keys, hiddenimports
andexcludes
. Their values are a list of the corresponding modules to include/exclude. This can be passed directly to Analysis` with e.g.a = Analysis(['..\kivy\examples\demo\touchtracer\main.py'], ... hookspath=hookspath(), runtime_hooks=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, **get_deps_minimal(video=None, audio=None))
-
kivy.tools.packaging.pyinstaller_hooks.
get_factory_modules
()[ソース]¶ Returns a list of all the modules registered in the kivy factory.
-
kivy.tools.packaging.pyinstaller_hooks.
get_hooks
()[ソース]¶ Returns the dict for the spec
hookspath
andruntime_hooks
values.
-
kivy.tools.packaging.pyinstaller_hooks.
hookspath
()[ソース]¶ Returns a list with the directory that contains the alternate (not the default included with pyinstaller) pyinstaller hook for kivy,
kivy/tools/packaging/pyinstaller_hooks/kivy-hook.py
. It is typically used withhookspath=hookspath()
in the spec file.The default pyinstaller hook returns all the core providers used using
get_deps_minimal()
to add to its list of hidden imports. This alternate hook only included the essential modules and leaves the core providers to be included additionally withget_deps_minimal()
orget_deps_all()
.