Skip to content

Commit

Permalink
Merge pull request #1 from keszybz/python-feature
Browse files Browse the repository at this point in the history
Make pyo3 dependency optional
  • Loading branch information
keszybz authored May 7, 2024
2 parents 308fda4 + 6710407 commit d415672
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ keywords = ["rpm", "reproducible-builds"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["python"]
python = ["dep:pyo3"]

[dependencies]
anyhow = "1.0.12"
chrono = "0.4.35"
clap = { version = "4.4.18", features = ["derive"] }
indoc = "2.0.4"
log = { version = "0.4", features = ["std"] }
nix = { version = "0.28.0", features = ["fs", "socket"] }
pyo3 = "0.20.0"
pyo3 = { version = "0.20.0", optional = true }
regex = { version = "1.10.0", default-features = false, features = ["std", "perf", "unicode-case"] }
time = "0.3.34"
walkdir = "2.5.0"
Expand Down
8 changes: 6 additions & 2 deletions src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
pub mod ar;
pub mod jar;
pub mod javadoc;

#[cfg(feature="python")]
pub mod pyc;

use anyhow::{Context, Result, anyhow};
Expand Down Expand Up @@ -42,10 +44,12 @@ pub trait Processor {

pub type HandlerBoxed = fn(&Rc<options::Config>) -> Box<dyn Processor>;

pub const HANDLERS: [(&str, HandlerBoxed); 4] = [
pub const HANDLERS: &[(&str, HandlerBoxed)] = &[
("ar", ar::Ar::boxed),
("jar", jar::Jar::boxed),
("javadoc", javadoc::Javadoc::boxed),

#[cfg(feature="python")]
("pyc", pyc::Pyc::boxed),
];

Expand All @@ -58,7 +62,7 @@ pub fn handler_names() -> Vec<&'static str> {
pub fn make_handlers(config: &Rc<options::Config>) -> Result<Vec<Box<dyn Processor>>> {
let mut handlers: Vec<Box<dyn Processor>> = vec![];

for (name, func) in &HANDLERS {
for (name, func) in HANDLERS {
if config.handler_names.contains(name) {
let mut handler = func(config);
match handler.initialize() {
Expand Down
2 changes: 2 additions & 0 deletions tests/test_handlers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod test_ar;
mod test_javadoc;

#[cfg(feature="python")]
mod test_pyc;

use anyhow::Result;
Expand Down

0 comments on commit d415672

Please sign in to comment.