Skip to content

Commit 390f8ef

Browse files
committed
Remove py03 dependency from standalone binary package
1 parent a254abb commit 390f8ef

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

crates/fastly-compute-py/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ path = "src/main.rs"
1212

1313
[features]
1414
default = ["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]
1919
clap = { version = "4", features = ["derive"] }
@@ -26,7 +26,7 @@ wit-component = "0.244"
2626
tempfile = "3"
2727
componentize-py = { git = "https://github.com/bytecodealliance/componentize-py" }
2828
futures = { version = "0.3", default-features = false, features = ["executor"] }
29-
pyo3 = { version = "0.27.2" }
29+
pyo3 = { version = "0.27.2", optional = true }
3030
serde = { version = "1.0", features = ["derive"] }
3131
toml = "0.8"
3232
log = "0.4"

crates/fastly-compute-py/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use anyhow::{Context, Result};
2-
use clap::Parser;
32
use indexmap::IndexMap;
43
use std::collections::HashMap;
54
use std::env;
@@ -17,6 +16,11 @@ pub mod config;
1716
pub mod site_packages;
1817

1918
use cli::Cli;
19+
20+
#[cfg(feature = "pyo3")]
21+
use clap::Parser;
22+
23+
#[cfg(feature = "pyo3")]
2024
use pyo3::prelude::*;
2125

2226
use 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]
100106
fn 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]
109116
fn _fastly_compute_py(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
110117
m.add_function(wrap_pyfunction!(run_main_py, m)?)?;

0 commit comments

Comments
 (0)