diff --git a/Cargo.toml b/Cargo.toml index f9a6772..fa970e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,27 @@ +[workspace] +publish = false +members = [ + "members/pt", + "members/pt-core", + "members/pt-math", + "members/pt-bin", + "members/pt-log", + "members/pt-net", + "members/pt-py", + "members/pt-hedu", +] +default-members = [ + "members/pt", + "members/pt-core", + "members/pt-py", + "members/pt-log", + "members/pt-math", +] + [package] +publish = false +autobins = true +default-run = "pt" name = "libpt" version = "0.1.6" edition = "2021" diff --git a/members/pt-bin/Cargo.toml b/members/pt-bin/Cargo.toml new file mode 100644 index 0000000..f7f64a7 --- /dev/null +++ b/members/pt-bin/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "pt-bin" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/members/pt-bin/src/main.rs b/members/pt-bin/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/members/pt-bin/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/members/pt-ccc/Cargo.toml b/members/pt-ccc/Cargo.toml new file mode 100644 index 0000000..768dcaa --- /dev/null +++ b/members/pt-ccc/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "pt-ccc" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/members/pt-ccc/src/main.rs b/members/pt-ccc/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/members/pt-ccc/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/members/pt-core/Cargo.toml b/members/pt-core/Cargo.toml new file mode 100644 index 0000000..bc9f747 --- /dev/null +++ b/members/pt-core/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "pt-core" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/members/pt-core/src/main.rs b/members/pt-core/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/members/pt-core/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/members/pt-hedu/Cargo.toml b/members/pt-hedu/Cargo.toml new file mode 100644 index 0000000..939f097 --- /dev/null +++ b/members/pt-hedu/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "pt-hedu" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/members/pt-hedu/src/main.rs b/members/pt-hedu/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/members/pt-hedu/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/members/pt-log/Cargo.toml b/members/pt-log/Cargo.toml new file mode 100644 index 0000000..5bd886f --- /dev/null +++ b/members/pt-log/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "pt-log" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/members/pt-log/src/main.rs b/members/pt-log/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/members/pt-log/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/members/pt-net/Cargo.toml b/members/pt-net/Cargo.toml new file mode 100644 index 0000000..cbf11a2 --- /dev/null +++ b/members/pt-net/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "pt-net" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/members/pt-net/src/main.rs b/members/pt-net/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/members/pt-net/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/members/pt-py/.github/workflows/CI.yml b/members/pt-py/.github/workflows/CI.yml new file mode 100644 index 0000000..8268eaf --- /dev/null +++ b/members/pt-py/.github/workflows/CI.yml @@ -0,0 +1,120 @@ +# This file is autogenerated by maturin v1.1.0 +# To update, run +# +# maturin generate-ci github +# +name: CI + +on: + push: + branches: + - main + - master + tags: + - '*' + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + linux: + runs-on: ubuntu-latest + strategy: + matrix: + target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --find-interpreter + sccache: 'true' + manylinux: auto + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + windows: + runs-on: windows-latest + strategy: + matrix: + target: [x64, x86] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + architecture: ${{ matrix.target }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --find-interpreter + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + macos: + runs-on: macos-latest + strategy: + matrix: + target: [x86_64, aarch64] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --find-interpreter + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + release: + name: Release + runs-on: ubuntu-latest + if: "startsWith(github.ref, 'refs/tags/')" + needs: [linux, windows, macos, sdist] + steps: + - uses: actions/download-artifact@v3 + with: + name: wheels + - name: Publish to PyPI + uses: PyO3/maturin-action@v1 + env: + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + with: + command: upload + args: --skip-existing * diff --git a/members/pt-py/.gitignore b/members/pt-py/.gitignore new file mode 100644 index 0000000..af3ca5e --- /dev/null +++ b/members/pt-py/.gitignore @@ -0,0 +1,72 @@ +/target + +# Byte-compiled / optimized / DLL files +__pycache__/ +.pytest_cache/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +.venv/ +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +include/ +man/ +venv/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt +pip-selfcheck.json + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot + +.DS_Store + +# Sphinx documentation +docs/_build/ + +# PyCharm +.idea/ + +# VSCode +.vscode/ + +# Pyenv +.python-version \ No newline at end of file diff --git a/members/pt-py/Cargo.toml b/members/pt-py/Cargo.toml new file mode 100644 index 0000000..4da490f --- /dev/null +++ b/members/pt-py/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "pt-py" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/pyproject.toml b/members/pt-py/pyproject.toml similarity index 100% rename from pyproject.toml rename to members/pt-py/pyproject.toml diff --git a/python/libpt/__init__.py b/members/pt-py/python/libpt/__init__.py similarity index 100% rename from python/libpt/__init__.py rename to members/pt-py/python/libpt/__init__.py diff --git a/python/libpt/__init__.pyi b/members/pt-py/python/libpt/__init__.pyi similarity index 100% rename from python/libpt/__init__.pyi rename to members/pt-py/python/libpt/__init__.pyi diff --git a/python/libpt/common/__init__.pyi b/members/pt-py/python/libpt/common/__init__.pyi similarity index 100% rename from python/libpt/common/__init__.pyi rename to members/pt-py/python/libpt/common/__init__.pyi diff --git a/python/libpt/common/printing.pyi b/members/pt-py/python/libpt/common/printing.pyi similarity index 100% rename from python/libpt/common/printing.pyi rename to members/pt-py/python/libpt/common/printing.pyi diff --git a/python/libpt/logger.pyi b/members/pt-py/python/libpt/logger.pyi similarity index 100% rename from python/libpt/logger.pyi rename to members/pt-py/python/libpt/logger.pyi diff --git a/python/libpt/networking/__init__.pyi b/members/pt-py/python/libpt/networking/__init__.pyi similarity index 100% rename from python/libpt/networking/__init__.pyi rename to members/pt-py/python/libpt/networking/__init__.pyi diff --git a/python/libpt/networking/monitoring/__init__.pyi b/members/pt-py/python/libpt/networking/monitoring/__init__.pyi similarity index 100% rename from python/libpt/networking/monitoring/__init__.pyi rename to members/pt-py/python/libpt/networking/monitoring/__init__.pyi diff --git a/python/libpt/networking/monitoring/uptime.pyi b/members/pt-py/python/libpt/networking/monitoring/uptime.pyi similarity index 100% rename from python/libpt/networking/monitoring/uptime.pyi rename to members/pt-py/python/libpt/networking/monitoring/uptime.pyi diff --git a/python/libpt/py.typed b/members/pt-py/python/libpt/py.typed similarity index 100% rename from python/libpt/py.typed rename to members/pt-py/python/libpt/py.typed diff --git a/members/pt-py/scripts/pytests.sh b/members/pt-py/scripts/pytests.sh new file mode 100755 index 0000000..1971c0c --- /dev/null +++ b/members/pt-py/scripts/pytests.sh @@ -0,0 +1 @@ +python -m unittest discover -fs tests/python diff --git a/members/pt-py/src/lib.rs b/members/pt-py/src/lib.rs new file mode 100644 index 0000000..fa8f42a --- /dev/null +++ b/members/pt-py/src/lib.rs @@ -0,0 +1,14 @@ +use pyo3::prelude::*; + +/// Formats the sum of two numbers as string. +#[pyfunction] +fn sum_as_string(a: usize, b: usize) -> PyResult { + Ok((a + b).to_string()) +} + +/// A Python module implemented in Rust. +#[pymodule] +fn pt_py(_py: Python, m: &PyModule) -> PyResult<()> { + m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; + Ok(()) +} \ No newline at end of file diff --git a/members/pt/Cargo.toml b/members/pt/Cargo.toml new file mode 100644 index 0000000..9099e7d --- /dev/null +++ b/members/pt/Cargo.toml @@ -0,0 +1,52 @@ +[package] +publish = true +autobins = true +default-run = "pt" +name = "libpt" +version = "0.1.6" +edition = "2021" +authors = ["Christoph J. Scherr "] +license = "GPL-3.0-or-later" +description = "Personal multitool" +readme = "README.md" +homepage = "https://git.cscherr.de/PlexSheep/pt" +repository = "https://git.cscherr.de/PlexSheep/pt" +keywords = ["cli", "python", "scriptable", "pyo3", "library"] +categories = ["command-line-utilities", "development-tools", "development-tools::ffi"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +name = "pt" +crate-type = ["cdylib", "rlib"] + +[[bin]] +name = "pt" +path = "src/bin/main/mod.rs" + +[[bin]] +name = "ccc" +path = "src/bin/ccc/mod.rs" + +[dependencies] +clap = { version = "4.3.11", features = ["derive"] } +clap-num = "1.0.2" +clap-verbosity-flag = "2.0.1" +env_logger = "0.10.0" +humantime = "2.1.0" +num = "0.4.0" +num-traits = "0.2.16" +openssl = "0.10.55" +openssl-sys = "0.9.90" +pyo3 = "0.18.1" +regex = "1.9.1" +reqwest = { version = "0.11.18", features = ["blocking"] } +serde = { version = "1.0.171", features = ["derive"] } +serde_json = "1.0.102" +signal-hook = "0.3.15" +tracing = "0.1.37" +tracing-appender = "0.2.2" +tracing-subscriber = "0.3.17" + +[dev-dependencies] +gag = "1.0.0" diff --git a/src/bin/ccc/mod.rs b/members/pt/src/bin/ccc/mod.rs similarity index 100% rename from src/bin/ccc/mod.rs rename to members/pt/src/bin/ccc/mod.rs diff --git a/src/bin/main/args.rs b/members/pt/src/bin/main/args.rs similarity index 100% rename from src/bin/main/args.rs rename to members/pt/src/bin/main/args.rs diff --git a/src/bin/main/mod.rs b/members/pt/src/bin/main/mod.rs similarity index 100% rename from src/bin/main/mod.rs rename to members/pt/src/bin/main/mod.rs diff --git a/src/common/macros.rs b/members/pt/src/common/macros.rs similarity index 100% rename from src/common/macros.rs rename to members/pt/src/common/macros.rs diff --git a/src/common/mod.rs b/members/pt/src/common/mod.rs similarity index 100% rename from src/common/mod.rs rename to members/pt/src/common/mod.rs diff --git a/src/common/printing.rs b/members/pt/src/common/printing.rs similarity index 100% rename from src/common/printing.rs rename to members/pt/src/common/printing.rs diff --git a/src/lib.rs b/members/pt/src/lib.rs similarity index 100% rename from src/lib.rs rename to members/pt/src/lib.rs diff --git a/src/logger/error.rs b/members/pt/src/logger/error.rs similarity index 100% rename from src/logger/error.rs rename to members/pt/src/logger/error.rs diff --git a/src/logger/mod.rs b/members/pt/src/logger/mod.rs similarity index 100% rename from src/logger/mod.rs rename to members/pt/src/logger/mod.rs diff --git a/src/math/calculator/base.rs b/members/pt/src/math/calculator/base.rs similarity index 100% rename from src/math/calculator/base.rs rename to members/pt/src/math/calculator/base.rs diff --git a/src/math/calculator/mod.rs b/members/pt/src/math/calculator/mod.rs similarity index 100% rename from src/math/calculator/mod.rs rename to members/pt/src/math/calculator/mod.rs diff --git a/src/math/calculator/term.rs b/members/pt/src/math/calculator/term.rs similarity index 100% rename from src/math/calculator/term.rs rename to members/pt/src/math/calculator/term.rs diff --git a/src/math/mod.rs b/members/pt/src/math/mod.rs similarity index 100% rename from src/math/mod.rs rename to members/pt/src/math/mod.rs diff --git a/src/networking/mod.rs b/members/pt/src/networking/mod.rs similarity index 100% rename from src/networking/mod.rs rename to members/pt/src/networking/mod.rs diff --git a/src/networking/monitoring/mod.rs b/members/pt/src/networking/monitoring/mod.rs similarity index 100% rename from src/networking/monitoring/mod.rs rename to members/pt/src/networking/monitoring/mod.rs diff --git a/src/networking/monitoring/uptime.rs b/members/pt/src/networking/monitoring/uptime.rs similarity index 100% rename from src/networking/monitoring/uptime.rs rename to members/pt/src/networking/monitoring/uptime.rs diff --git a/src/template.rs b/members/pt/src/template.rs similarity index 100% rename from src/template.rs rename to members/pt/src/template.rs diff --git a/tests/bin.rs b/members/pt/tests/bin.rs similarity index 100% rename from tests/bin.rs rename to members/pt/tests/bin.rs diff --git a/tests/lib.rs b/members/pt/tests/lib.rs similarity index 100% rename from tests/lib.rs rename to members/pt/tests/lib.rs diff --git a/tests/python/__init__.py b/members/pt/tests/python/__init__.py similarity index 100% rename from tests/python/__init__.py rename to members/pt/tests/python/__init__.py diff --git a/tests/python/lib.py b/members/pt/tests/python/lib.py similarity index 100% rename from tests/python/lib.py rename to members/pt/tests/python/lib.py diff --git a/tests/python/test_logger.py b/members/pt/tests/python/test_logger.py similarity index 100% rename from tests/python/test_logger.py rename to members/pt/tests/python/test_logger.py diff --git a/tests/test_logger_struct.rs b/members/pt/tests/test_logger_struct.rs similarity index 100% rename from tests/test_logger_struct.rs rename to members/pt/tests/test_logger_struct.rs