File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ path = "src/main.rs"
1212
1313[features ]
1414default = [" extension-module" ]
15- extension-module = [" pyo3/extension-module" ]
16- binary = [" pyo3/auto-initialize " ]
15+ extension-module = [" pyo3/extension-module" , " pyo3 " ]
16+ binary = [] # Binary feature doesn't need pyo3
1717
1818[dependencies ]
1919clap = { version = " 4" , features = [" derive" ] }
@@ -26,7 +26,7 @@ wit-component = "0.244"
2626tempfile = " 3"
2727componentize-py = { git = " https://github.com/bytecodealliance/componentize-py" }
2828futures = { version = " 0.3" , default-features = false , features = [" executor" ] }
29- pyo3 = { version = " 0.27.2" }
29+ pyo3 = { version = " 0.27.2" , optional = true }
3030serde = { version = " 1.0" , features = [" derive" ] }
3131toml = " 0.8"
3232log = " 0.4"
Original file line number Diff line number Diff line change 11use anyhow:: { Context , Result } ;
2- use clap:: Parser ;
32use indexmap:: IndexMap ;
43use std:: collections:: HashMap ;
54use std:: env;
@@ -17,6 +16,11 @@ pub mod config;
1716pub mod site_packages;
1817
1918use cli:: Cli ;
19+
20+ #[ cfg( feature = "pyo3" ) ]
21+ use clap:: Parser ;
22+
23+ #[ cfg( feature = "pyo3" ) ]
2024use pyo3:: prelude:: * ;
2125
2226use crate :: config:: ConfigBuilder ;
@@ -96,6 +100,8 @@ pub fn run_main(cli: &Cli) -> Result<()> {
96100 Ok ( ( ) )
97101}
98102
103+ // Python bindings - only compiled when building the Python extension module
104+ #[ cfg( feature = "pyo3" ) ]
99105#[ pyfunction]
100106fn run_main_py ( args : Vec < String > ) -> PyResult < ( ) > {
101107 let cli = Cli :: parse_from ( args) ;
@@ -105,6 +111,7 @@ fn run_main_py(args: Vec<String>) -> PyResult<()> {
105111 } )
106112}
107113
114+ #[ cfg( feature = "pyo3" ) ]
108115#[ pymodule]
109116fn _fastly_compute_py ( _py : Python , m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
110117 m. add_function ( wrap_pyfunction ! ( run_main_py, m) ?) ?;
You can’t perform that action at this time.
0 commit comments