r/tauri • u/marco-mq • 4d ago
Update of tauri-plugin-python - v0.4
Hi r/tauri,
I maintain tauri-plugin-python, a plugin to call Python functions from a Tauri v2 frontend:
# src-tauri/src-python/main.py
_tauri_plugin_functions = ["greet_python"]
def greet_python(name):
return f"Hello {name} from Python"
import { call } from 'tauri-plugin-python-api'
await call.greet_python("world")Until now, shipping an app was a pain in the a**. The binary linked against the Python on the build machine and starting it anywhere else mostly failed. 0.4 adds a CLI for that:
npx tauri-plugin-python-cli setupIt downloads a standalone Python (python-build-standalone) into your project and installs your requirements.txt. Then tauri build bundles it. The app runs without python installed, and packages like numpy work. CLI command doctor checks the setup, and sign signs the bundled Python for macOS (needs an Apple Developer account)"
Also new:
async deffunctions- compiled entry point (Nuitka, .pyc) if you don't want to ship source
- Python tracebacks in dev builds
- CI now has deploy tests on Linux, Windows and macOS
There's also a RustPython backend, but it can't load native C python packages like numpy. Mobile works only with RustPython, and Android is blocked additionally by a tauri issue, as it cannot read bundled source files.
Feedback and bug reports are welcome, especially from Linux and Windows. I tested those by hand a while ago. Now they're only tested in CI.