Merge branch 'devel'

This commit is contained in:
Christoph J. Scherr 2023-09-29 18:24:50 +02:00
commit ceb8c98715
48 changed files with 179 additions and 68 deletions

View File

@ -2,22 +2,22 @@
resolver = "2" resolver = "2"
members = [ members = [
".", ".",
"members/pt-core", "members/libpt-core",
"members/pt-bintols", "members/libpt-bintols",
"members/pt-math", "members/libpt-math",
"members/pt-bin", "members/libpt-bin",
"members/pt-log", "members/libpt-log",
"members/pt-net", "members/libpt-net",
"members/pt-py", "members/libpt-py",
"members/pt-hedu", "members/libpt-hedu",
] ]
default-members = [ default-members = [
".", ".",
"members/pt-bin", "members/libpt-bin",
"members/pt-core", "members/libpt-core",
"members/pt-py", "members/libpt-py",
"members/pt-log", "members/libpt-log",
"members/pt-math", "members/libpt-math",
] ]
[workspace.package] [workspace.package]
publish = false publish = false
@ -27,8 +27,8 @@ authors = ["Christoph J. Scherr <software@cscherr.de>"]
license = "MIT" license = "MIT"
description = "Personal multitool" description = "Personal multitool"
readme = "README.md" readme = "README.md"
homepage = "https://git.cscherr.de/PlexSheep/pt" homepage = "https://git.cscherr.de/PlexSheep/libpt"
repository = "https://git.cscherr.de/PlexSheep/pt" repository = "https://git.cscherr.de/PlexSheep/libpt"
keywords = ["cli", "python", "scriptable", "pyo3", "library"] keywords = ["cli", "python", "scriptable", "pyo3", "library"]
categories = ["command-line-utilities", "development-tools", "development-tools::ffi"] categories = ["command-line-utilities", "development-tools", "development-tools::ffi"]
@ -50,8 +50,17 @@ keywords.workspace = true
categories.workspace = true categories.workspace = true
[features] [features]
default = ["core", "log"] default = ["log"]
core = [] all = [
"default",
"math",
"log",
"bintols",
"net",
"ccc",
"hedu"
]
fw = []
math = [] math = []
log = [] log = []
bintols = [] bintols = []
@ -63,16 +72,17 @@ hedu = ["bintols"]
name = "libpt" name = "libpt"
crate-type = [ crate-type = [
"dylib", # .dll, .so, .dynlib "dylib", # .dll, .so, .dynlib
"staticlib" # .lib, .a "staticlib", # .lib, .a
"rlib"
] ]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
pt-bintols = { version = "0.1.0", path = "members/pt-bintols" } libpt-bintols = { version = "0.1.7", path = "members/libpt-bintols" }
pt-core = { version = "0.1.0", path = "members/pt-core" } libpt-core = { version = "0.1.7", path = "members/libpt-core" }
pt-hedu = { version = "0.1.0", path = "members/pt-hedu" } libpt-hedu = { version = "0.1.7", path = "members/libpt-hedu" }
pt-log = { version = "0.1.0", path = "members/pt-log" } libpt-log = { version = "0.1.7", path = "members/libpt-log" }
pt-math = { version = "0.1.0", path = "members/pt-math" } libpt-math = { version = "0.1.7", path = "members/libpt-math" }
pt-net = { version = "0.1.0", path = "members/pt-net" } libpt-net = { version = "0.1.7", path = "members/libpt-net" }
pt-ccc = { version = "0.1.0", path = "members/pt-ccc" } libpt-ccc = { version = "0.1.7", path = "members/libpt-ccc" }

View File

@ -1,6 +1,6 @@
[package] [package]
autobins = true autobins = true
name = "pt-bin" name = "libpt-bin"
publish.workspace = true publish.workspace = true
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
@ -20,7 +20,7 @@ name = "ccc"
path = "src/ccc/mod.rs" path = "src/ccc/mod.rs"
[[bin]] [[bin]]
name = "pt" name = "libpt"
path = "src/main/mod.rs" path = "src/main/mod.rs"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
//! # args module //! # args module
//! //!
//! The args module of pt is used to parse commandline arguments. For this, it makes use of //! The args module of libpt is used to parse commandline arguments. For this, it makes use of
//! [`clap`]. //! [`clap`].
//// ATTRIBUTES //////////////////////////////////////////////////////////////////////////////////// //// ATTRIBUTES ////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,4 @@
//! # Main executable of pt //! # Main executable of libpt
//! //!
//! This module contains all code specific to the executable version of [`pt`]: [`pt`](crate). //! This module contains all code specific to the executable version of [`pt`]: [`pt`](crate).
//! //!

View File

@ -1,5 +1,5 @@
[package] [package]
name = "pt-bintols" name = "libpt-bintols"
publish.workspace = true publish.workspace = true
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
@ -16,5 +16,5 @@ categories.workspace = true
[dependencies] [dependencies]
num-traits = "0.2.16" num-traits = "0.2.16"
pt-core = { version = "0.1.0", path = "../pt-core" } libpt-core = { version = "0.1.0", path = "../libpt-core" }
pt-log = { version = "0.1.0", path = "../pt-log" } libpt-log = { version = "0.1.0", path = "../libpt-log" }

View File

@ -22,6 +22,6 @@ pub const ZEBI: u128 = 2u128.pow(70);
/// 2^80 /// 2^80
pub const YOBI: u128 = 2u128.pow(80); pub const YOBI: u128 = 2u128.pow(80);
// use pt_core; // use libpt_core;
pub mod datalayout; pub mod datalayout;
pub mod display; pub mod display;

View File

@ -1,4 +1,4 @@
use pt_bintols::*; use libpt_bintols::*;
#[test] #[test]
fn mkdmp() { fn mkdmp() {

View File

@ -1,5 +1,5 @@
use pt_bintols::*; use libpt_bintols::*;
use pt_bintols::display::*; use libpt_bintols::display::*;
#[test] #[test]
fn btobin() { fn btobin() {

View File

@ -1,5 +1,5 @@
[package] [package]
name = "pt-ccc" name = "libpt-ccc"
publish.workspace = true publish.workspace = true
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
@ -17,6 +17,6 @@ categories.workspace = true
[dependencies] [dependencies]
num = "0.4.1" num = "0.4.1"
num-traits = "0.2.16" num-traits = "0.2.16"
pt-core = { version = "0.1.7", path = "../pt-core" } libpt-core = { version = "0.1.7", path = "../libpt-core" }
pt-log = { version = "0.1.7", path = "../pt-log" } libpt-log = { version = "0.1.7", path = "../libpt-log" }
pt-math = { version = "0.1.7", path = "../pt-math" } libpt-math = { version = "0.1.7", path = "../libpt-math" }

View File

@ -16,9 +16,9 @@ use std::fmt::Display;
pub use num_traits::PrimInt; pub use num_traits::PrimInt;
#[allow(unused_imports)] // we possibly want to use all log levels #[allow(unused_imports)] // we possibly want to use all log levels
use pt_log::*; use libpt_log::*;
#[allow(unused_imports)] // import more complex math stuff from there #[allow(unused_imports)] // import more complex math stuff from there
use pt_math; use libpt_math;
//// TYPES ///////////////////////////////////////////////////////////////////////////////////////// //// TYPES /////////////////////////////////////////////////////////////////////////////////////////
/// Quick Result with a ccc error /// Quick Result with a ccc error

View File

@ -25,9 +25,9 @@ pub mod term;
pub use term::*; pub use term::*;
#[allow(unused_imports)] // we possibly want to use all log levels #[allow(unused_imports)] // we possibly want to use all log levels
use pt_log::*; use libpt_log::*;
#[allow(unused_imports)] // import more complex math stuff from there #[allow(unused_imports)] // import more complex math stuff from there
use pt_math; use libpt_math;
//// TYPES ///////////////////////////////////////////////////////////////////////////////////////// //// TYPES /////////////////////////////////////////////////////////////////////////////////////////

View File

@ -22,9 +22,9 @@ use std::collections::VecDeque;
//// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// //// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////
pub use super::{Error, Result, Value, base::{self, *}}; pub use super::{Error, Result, Value, base::{self, *}};
#[allow(unused_imports)] // we possibly want to use all log levels #[allow(unused_imports)] // we possibly want to use all log levels
use pt_log::*; use libpt_log::*;
#[allow(unused_imports)] // import more complex math stuff from there #[allow(unused_imports)] // import more complex math stuff from there
use pt_math; use libpt_math;
//// TYPES ///////////////////////////////////////////////////////////////////////////////////////// //// TYPES /////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
[package] [package]
name = "pt-core" name = "libpt-core"
publish.workspace = true publish.workspace = true
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true

View File

@ -1,5 +1,5 @@
[package] [package]
name = "pt-hedu" name = "libpt-hedu"
publish.workspace = true publish.workspace = true
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true

View File

@ -1,5 +1,5 @@
[package] [package]
name = "pt-log" name = "libpt-log"
publish.workspace = true publish.workspace = true
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true

View File

@ -105,7 +105,7 @@ impl Logger {
// //
// // if it's this lib, continue // // if it's this lib, continue
// filter |= metadata.target().contains(env!("CARGO_PKG_NAME")); // filter |= metadata.target().contains(env!("CARGO_PKG_NAME"));
// filter |= metadata.target().contains("pt"); // filter |= metadata.target().contains("libpt");
// //
// // if it's another crate, only show above debug // // if it's another crate, only show above debug
// filter |= metadata.level() > &Level::DEBUG; // filter |= metadata.level() > &Level::DEBUG;

View File

@ -1,5 +1,5 @@
[package] [package]
name = "pt-math" name = "libpt-math"
publish.workspace = true publish.workspace = true
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true

View File

@ -1,5 +1,5 @@
[package] [package]
name = "pt-net" name = "libpt-net"
publish.workspace = true publish.workspace = true
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
@ -16,9 +16,9 @@ categories.workspace = true
[dependencies] [dependencies]
humantime = "2.1.0" humantime = "2.1.0"
pt-core = { version = "0.1.0", path = "../pt-core" } libpt-core = { version = "0.1.0", path = "../libpt-core" }
pt-log = { version = "0.1.0", path = "../pt-log" } libpt-log = { version = "0.1.0", path = "../libpt-log" }
pt-math = { version = "0.1.0", path = "../pt-math" } libpt-math = { version = "0.1.0", path = "../libpt-math" }
reqwest = { version = "0.11.20", features = ["blocking"] } reqwest = { version = "0.11.20", features = ["blocking"] }
serde = { version = "1.0.188", features = ["serde_derive"] } serde = { version = "1.0.188", features = ["serde_derive"] }
serde_json = "1.0.107" serde_json = "1.0.107"

View File

@ -19,7 +19,7 @@
use std::{fmt, time::Duration}; use std::{fmt, time::Duration};
//// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// //// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////
use pt_log::*; use libpt_log::*;
use reqwest; use reqwest;
@ -29,7 +29,7 @@ use std::time::SystemTime;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json; use serde_json;
use pt_core::divider; use libpt_core::divider;
//// TYPES ///////////////////////////////////////////////////////////////////////////////////////// //// TYPES /////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
[package] [package]
name = "pt-py" name = "libpt-py"
publish.workspace = true publish.workspace = true
version.workspace = true version.workspace = true
edition.workspace = true edition.workspace = true
@ -14,9 +14,9 @@ categories.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib] [lib]
name = "pt_py" name = "libpt_py"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
libpt = { version = "0.1.7", path = "../..", features = ["all"] }
pyo3 = { workspace = true } pyo3 = { workspace = true }
libpt = { version = "0.1.7", path = "../../" }

View File

@ -16,7 +16,7 @@ classifiers = [
] ]
[project.urls] [project.urls]
Homepage = "https://git.cscherr.de/PlexSheep/pt" Homepage = "https://git.cscherr.de/PlexSheep/libpt"
[tool.maturin] [tool.maturin]

101
members/libpt-py/src/lib.rs Normal file
View File

@ -0,0 +1,101 @@
// FIXME: Using a local dependency does not work with maturin as it seems?
use libpt::{
log::*,
};
use pyo3::prelude::*;
//// PUBLIC FUNCTIONS //////////////////////////////////////////////////////////////////////////////
/// ## Check if [`libpt`](crate) has been loaded
///
/// Always returns `true` if you can execute it.
#[pyfunction]
pub fn is_loaded() -> bool {
true
}
//// PRIVATE FUNCTIONS /////////////////////////////////////////////////////////////////////////////
/// ## Python module: logger
#[pymodule]
fn py_logger(py: Python, parent: &PyModule) -> PyResult<()> {
let module = PyModule::new(py, "logger")?;
module.add_class::<Logger>()?;
parent.add_submodule(module)?;
Ok(())
}
//
// ////////////////////////////////////////////////////////////////////////////////////////////////////
// /// ## Python module: common
// #[pymodule]
// fn py_common(py: Python, parent: &PyModule) -> PyResult<()> {
// let module = PyModule::new(py, "common")?;
// py_common_printing(py, module)?;
//
// parent.add_submodule(module)?;
// Ok(())
// }
//
// ////////////////////////////////////////////////////////////////////////////////////////////////////
// /// ## Python module: common.printing
// #[pymodule]
// fn py_common_printing(py: Python, parent: &PyModule) -> PyResult<()> {
// let module = PyModule::new(py, "printing")?;
// module.add_function(wrap_pyfunction!(common::printing::divider, module)?)?;
// module.add_function(wrap_pyfunction!(common::printing::print_divider, module)?)?;
//
// parent.add_submodule(module)?;
// Ok(())
// }
//
// ////////////////////////////////////////////////////////////////////////////////////////////////////
// /// ## Python module: networking
// #[pymodule]
// fn py_networking(py: Python, parent: &PyModule) -> PyResult<()> {
// let module = PyModule::new(py, "networking")?;
// py_networking_monitoring(py, module)?;
//
// parent.add_submodule(module)?;
// Ok(())
// }
//
// ////////////////////////////////////////////////////////////////////////////////////////////////////
// /// ## Python module: networking.monitoring
// #[pymodule]
// fn py_networking_monitoring(py: Python, parent: &PyModule) -> PyResult<()> {
// let module = PyModule::new(py, "monitoring")?;
// py_networking_monitoring_uptime(py, module)?;
//
// parent.add_submodule(module)?;
// Ok(())
// }
//
// ////////////////////////////////////////////////////////////////////////////////////////////////////
// /// ## Python module: networking.monitoring.uptime
// #[pymodule]
// fn py_networking_monitoring_uptime(py: Python, parent: &PyModule) -> PyResult<()> {
// let module = PyModule::new(py, "uptime")?;
// module.add_class::<networking::monitoring::uptime::UptimeStatus>()?;
// module.add_function(wrap_pyfunction!(
// networking::monitoring::uptime::py_continuous_uptime_monitor,
// module
// )?)?;
//
// parent.add_submodule(module)?;
// Ok(())
// }
////////////////////////////////////////////////////////////////////////////////////////////////////
/// ## Python module: root
///
/// This function is the entry point of [`PyO3`](pyo3). This is where the main module is built.
#[pymodule]
fn _libpt(py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(is_loaded, m)?)?;
// load sub modules
// py_common(py, m)?;
py_logger(py, m)?;
// py_networking(py, m)?;
Ok(())
}

View File

@ -7,16 +7,16 @@
//! "main crate". Most crates will only show up if you activate their feature. //! "main crate". Most crates will only show up if you activate their feature.
#[cfg(feature = "core")] #[cfg(feature = "core")]
pub use pt_core as core; pub use libpt_core as core;
#[cfg(feature = "bintols")] #[cfg(feature = "bintols")]
pub use pt_bintols as bintols; pub use libpt_bintols as bintols;
#[cfg(feature = "hedu")] #[cfg(feature = "hedu")]
pub use pt_hedu as hedu; pub use libpt_hedu as hedu;
#[cfg(feature = "log")] #[cfg(feature = "log")]
pub use pt_log as log; pub use libpt_log as log;
#[cfg(feature = "math")] #[cfg(feature = "math")]
pub use pt_math as math; pub use libpt_math as math;
#[cfg(feature = "net")] #[cfg(feature = "net")]
pub use pt_net as net; pub use libpt_net as net;
#[cfg(feature = "ccc")] #[cfg(feature = "ccc")]
pub use pt_ccc as ccc; pub use libpt_ccc as ccc;