File tree Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " tauri-plugin-python"
3
- version = " 0.3.3 "
3
+ version = " 0.3.4 "
4
4
authors = [ " Marco Mengelkoch" ]
5
5
description = " A tauri 2 plugin to use python code in the backend."
6
6
keywords = [" rust" , " python" , " tauri" , " gui" ]
@@ -31,5 +31,7 @@ serde_json = "1.0.136"
31
31
tauri-plugin = { version = " 2" , features = [" build" ] }
32
32
33
33
[features ]
34
- # default = ["pyo3"] # enable to use pyo3 instead of rustpython
34
+ venv = []
35
+ default = [" venv" ] # auto load src-python/.venv
36
+ # default = ["venv", "pyo3"] # enable to use pyo3 instead of rustpython
35
37
pyo3 = [" dep:pyo3" ]
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " tauri-plugin-python-api" ,
3
- "version" : " 0.3.3 " ,
3
+ "version" : " 0.3.4 " ,
4
4
"author" : " Marco Mengelkoch" ,
5
5
"description" : " Javascript package for tauri 2 python plugin." ,
6
6
"type" : " module" ,
Original file line number Diff line number Diff line change @@ -80,16 +80,20 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
80
80
}
81
81
82
82
fn init_python ( code : String , dir : PathBuf ) {
83
+ #[ allow( unused_mut) ]
83
84
let mut sys_pyth_dir = format ! ( "sys.path.append('{}')" , dir. to_str( ) . unwrap( ) ) ;
84
- let venv_dir = dir. join ( ".venv" ) . join ( "lib" ) ;
85
- if Path :: exists ( venv_dir. as_path ( ) ) {
86
- if let Ok ( py_dir) = venv_dir. read_dir ( ) {
87
- for entry in py_dir. flatten ( ) {
88
- let site_packages = entry. path ( ) . join ( "site-packages" ) ;
89
- if Path :: exists ( site_packages. as_path ( ) ) { // use first site-packages found, ignoring version
90
- sys_pyth_dir += "\n " ;
91
- sys_pyth_dir += & format ! ( "sys.path.append('{}')" , site_packages. to_str( ) . unwrap( ) ) ;
92
- break ;
85
+ #[ cfg( feature = "venv" ) ]
86
+ {
87
+ let venv_dir = dir. join ( ".venv" ) . join ( "lib" ) ;
88
+ if Path :: exists ( venv_dir. as_path ( ) ) {
89
+ if let Ok ( py_dir) = venv_dir. read_dir ( ) {
90
+ for entry in py_dir. flatten ( ) {
91
+ let site_packages = entry. path ( ) . join ( "site-packages" ) ;
92
+ if Path :: exists ( site_packages. as_path ( ) ) { // use first site-packages found, ignoring version
93
+ sys_pyth_dir += "\n " ;
94
+ sys_pyth_dir += & format ! ( "sys.path.append('{}')" , site_packages. to_str( ) . unwrap( ) ) ;
95
+ break ;
96
+ }
93
97
}
94
98
}
95
99
}
You can’t perform that action at this time.
0 commit comments