From 716e07b6887ca2b0343f943842378543a53659df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Stucke?= Date: Thu, 8 Aug 2024 13:52:42 +0200 Subject: [PATCH 1/2] readme: mention need for rust when installing from source --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 57441e4..57bd6c6 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,11 @@ To install the version from pypi.org run pip install entropython ``` -To install the newest version from this repository run +To install the latest version directly from GitHub run ```shell pip git+https://github.com/fkie-cad/entropython ``` - +(you need to [have rust installed](https://www.rust-lang.org/tools/install)) or check out the repository and run ```shell pip install . From 7753a3e371139e936518f6a53131476786094067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Stucke?= Date: Thu, 8 Aug 2024 14:10:50 +0200 Subject: [PATCH 2/2] update pyo3 version and Rust edition --- Cargo.toml | 12 ++++-------- rust/lib.rs | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fc56b6f..80ecbed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "entropython" -version = "1.1.0" +version = "1.1.1" authors = ["Enkelmann "] -edition = "2018" +edition = "2021" description = "A Python module for efficient calculation of Shannon byte entropy based on Rust." readme = "README.md" homepage = "https://github.com/fkie-cad/entropython" @@ -16,9 +16,5 @@ name = "libentropython" path = "rust/lib.rs" crate-type = ["cdylib"] -[dependencies.pyo3] -version = "0.17.1" - -[features] -extension-module = ["pyo3/extension-module"] -default = ["extension-module"] +[dependencies] +pyo3 = { version = "0.22.2", features = ["extension-module"] } diff --git a/rust/lib.rs b/rust/lib.rs index 01f0935..effd851 100644 --- a/rust/lib.rs +++ b/rust/lib.rs @@ -37,7 +37,7 @@ fn metric_entropy(bytes: &[u8]) -> f64 { /// This module implements functions to compute the Shannon byte entropy of a byte array. /// The computation itself is implemented in Rust for faster runtime. #[pymodule] -fn libentropython(_py: Python, m: &PyModule) -> PyResult<()> { +fn libentropython(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(shannon_entropy, m)?)?; m.add_function(wrap_pyfunction!(metric_entropy, m)?)?; Ok(()) @@ -60,4 +60,4 @@ mod tests { assert!(shannon_entropy(&bytes) > 7.99f64); assert!(shannon_entropy(&bytes) <= 8f64); } -} +} \ No newline at end of file