# Freezing
# Android
pywebview is designed to be built with buildozer (opens new window). You need to include following lines in your buildozer.spec
to bundle pywebview correctly
requirements = python3,kivy,pywebview
android.add_jars = <path_to_pywebview-android.jar>
pywebview-android.jar
is shipped with pywebview
and can be found under site-packages/pywebview/lib
. To get its full path type
from webview import util
print(util.android_jar_path())
You can see a sample bulldozer.spec
here (opens new window)
# macOS
Use py2app (opens new window). For a reference setup.py for py2app, look here (opens new window).
# Windows / Linux
Use pyinstaller (opens new window). Pyinstaller picks all the dependencies found in pywebview
, even if you don't use them. So for example if you have PyQt
installed, but use EdgeChromium
renderer on Windows, pyinstaller will bundle PyQT
all the same. To prevent that you might want to add unwanted dependencies to excludes
in your spec file.
Basic pyinstaller script to package an application which uses index.html as content
pyinstaller main.py --add-data index.html:.
For one file build
pyinstaller main.py --add-data index.html:. --onefile
[!warning] In Linux if you get a
cannot find python3.xx.so error
you must add it to the pyinstaller binary list for the application to work (replace 'x' with python version)pyinstaller main.py --add-data index.html:. --add-binary /usr/lib/x86_64-linux-gnu/libpython3.x.so:. --onefile
In case of using a Javascript library like vue or react you can build the project and use the build directory to the pyinstaller --add-data
.
[!warning] While using vite change the build directory to something else to not conflict with pyinstller's build directory which is also
./dist
Here is a script to build a vue/react app with pyinstaller (assuming output is your new build directory)
pyinstaller main.py --add-data output:.
Onefile
pyinstaller main.py --add-data output:. --onefile
You can also use nuitka (opens new window) for packaging. Nuitka does the same, although it is a bit more configurable. You might want to use --nofollow-import-to
to exclude unwanted dependencies.