Make jemalloc, clap and pyo3 optional dependencies (#116)

This commit is contained in:
msrd0
2023-04-21 14:17:35 +02:00
committed by GitHub
parent f4d96c73a8
commit 6a065de6fc
4 changed files with 37 additions and 9 deletions

View File

@@ -4,6 +4,10 @@ authors = ["William Ashton"]
version = "0.1.3"
edition = "2018"
[[bin]]
name = "synapse_auto_compressor"
required-features = ["clap"]
[package.metadata.maturin]
requires-python = ">=3.7"
project-url = {Source = "https://github.com/matrix-org/rust-synapse-compress-state"}
@@ -18,12 +22,11 @@ postgres = "0.19.0"
postgres-openssl = "0.5.0"
rand = "0.8.0"
serial_test = "0.9.0"
synapse_compress_state = { path = "../", features = ["no-progress-bars"] }
synapse_compress_state = { path = "../", features = ["no-progress-bars"], default-features = false }
env_logger = "0.9.0"
log = "0.4.14"
log-panics = "2.0.0"
anyhow = "1.0.42"
pyo3-log = "0.7.0"
# Needed for pyo3 support
[lib]
@@ -32,15 +35,22 @@ crate-type = ["cdylib", "rlib"]
[dependencies.clap]
version = "4.0.15"
features = ["cargo"]
optional = true
[dependencies.pyo3]
version = "0.17.1"
features = ["extension-module"]
optional = true
[dependencies.pyo3-log]
version = "0.7.0"
optional = true
[dependencies.tikv-jemallocator]
version = "0.5.0"
optional = true
[features]
default = ["jemalloc"]
jemalloc = ["tikv-jemallocator"]
default = ["clap", "jemalloc", "pyo3"]
jemalloc = ["tikv-jemallocator", "synapse_compress_state/jemalloc"]
pyo3 = ["dep:pyo3", "dep:pyo3-log", "synapse_compress_state/pyo3"]

View File

@@ -7,7 +7,9 @@
//! on space reductions
use anyhow::Result;
#[cfg(feature = "pyo3")]
use log::{error, LevelFilter};
#[cfg(feature = "pyo3")]
use pyo3::{
exceptions::PyRuntimeError, prelude::pymodule, types::PyModule, PyErr, PyResult, Python,
};
@@ -56,6 +58,7 @@ impl FromStr for LevelInfo {
}
// PyO3 INTERFACE STARTS HERE
#[cfg(feature = "pyo3")]
#[pymodule]
fn synapse_auto_compressor(_py: Python, m: &PyModule) -> PyResult<()> {
let _ = pyo3_log::Logger::default()