|
1 | 1 | # Tauri Plugin Python |
2 | 2 |
|
3 | 3 | This [tauri](https://v2.tauri.app/) plugin is supposed to make it easy to use Python as backend code. |
4 | | -It uses [RustPython](https://github.com/RustPython/RustPython) as interpreter to call python from rust. |
| 4 | +It uses [RustPython](https://github.com/RustPython/RustPython) or alternatively [PyO3](https://pyo3.rs) as interpreter to call python from rust. |
| 5 | + |
5 | 6 | RustPython doesn't require python to be installed on the target platform and makes it |
6 | 7 | therefore easy to deploy your production binary. Unfortunately, it has some |
7 | | -compatibility issues and is slower than PyO3/CPython. [PyO3](https://pyo3.rs) is also supported as optional Cargo feature for desktop applications. |
8 | | -PyO3 uses CPython as interpreter and therefore has a much better compatibility for python libraries. |
| 8 | +compatibility issues and is slower than PyO3/CPython. PyO3 is also supported as optional Cargo feature for desktop applications. |
| 9 | +PyO3 uses CPython as interpreter and therefore has a wide compatibility for available python libraries. |
9 | 10 | It isn't used as default as it requires to make libpython available for the target platform, |
10 | 11 | which can be complicated, especially for mobile targets. |
11 | 12 |
|
@@ -41,6 +42,14 @@ is not available for rust yet. |
41 | 42 | In case that you want to ship production software packages, you need |
42 | 43 | to make sure to also ship all your python code. If you use PyO3, you also need to ship libpython too. |
43 | 44 |
|
| 45 | +### Switch from RustPython to PyO3 |
| 46 | + |
| 47 | +```toml |
| 48 | +# src-tauri/Cargo.toml |
| 49 | +tauri-plugin-python = { version="0.3", , features = ["pyo3"] } |
| 50 | + |
| 51 | +``` |
| 52 | + |
44 | 53 | ## Example app |
45 | 54 |
|
46 | 55 | There is a sample Desktop application for Windows/Linux/MacOS using this plugin and vanilla |
@@ -109,9 +118,10 @@ The included resources can be configurable in the `tauri.conf.json` file. |
109 | 118 | Check the tauri and PyO3 documentation for additional info. |
110 | 119 |
|
111 | 120 | ## Security considerations |
112 | | -Generally, this plugin has been created by "security by default" concept. Python functions can only be called if registered from rust during plugin initialization. |
| 121 | +By default, this plugin cannot call arbitrary python code. Python functions can only be called if registered from rust during plugin initialization. |
| 122 | +It may still be possible to read values from python. This can be prevented via additional tauri permissions. |
113 | 123 |
|
114 | | -Keep in mind that this plugin could make it possible to run arbitrary python code. |
| 124 | +Keep in mind that this plugin could make it possible to run arbitrary python code when using all allow permissions. |
115 | 125 | It is therefore highly recommended to **make sure the user interface is not accessible by a network URL** in production. |
116 | 126 |
|
117 | 127 | The "runPython" command is disabled by default via permissions. If enabled, it is possible to |
|
0 commit comments