From 37f4d8f84c28dab267c4557bf49cc77901efd3f2 Mon Sep 17 00:00:00 2001 From: Andy Pack <andy@sarsoo.xyz> Date: Sat, 15 Feb 2025 20:27:44 +0000 Subject: [PATCH] rearranging ffi mods, adding wasm and python builds --- .gitea/workflows/build.yml | 45 +++++++++++++++++++++++++- Cargo.lock | 8 ++--- Cargo.toml | 2 +- finlib/src/ffi/mod.rs | 4 +++ finlib/src/{ => ffi}/py/mod.rs | 0 finlib/src/{ => ffi}/py/portfolio.rs | 0 finlib/src/{ => ffi}/wasm/mod.rs | 0 finlib/src/{ => ffi}/wasm/portfolio.rs | 0 finlib/src/lib.rs | 5 +-- 9 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 finlib/src/ffi/mod.rs rename finlib/src/{ => ffi}/py/mod.rs (100%) rename finlib/src/{ => ffi}/py/portfolio.rs (100%) rename finlib/src/{ => ffi}/wasm/mod.rs (100%) rename finlib/src/{ => ffi}/wasm/portfolio.rs (100%) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index efa3f7d..ab7e4e1 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -72,10 +72,53 @@ jobs: command: publish args: --package finlib + buildWASM: + name: Build WASM + runs-on: ubuntu-latest + needs: [ build ] # for ignoring bad builds + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + github-server-url: https://gitea.sheep-ghoul.ts.net + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Build Rust for WASM + working-directory: ./finlib-wasm + run: wasm-pack build + + buildPy: + name: Build Python + runs-on: ubuntu-latest + needs: [ build ] # for ignoring bad builds + steps: + - uses: actions/checkout@v4 # get source + with: + github-server-url: https://gitea.sheep-ghoul.ts.net + + - name: Install Python 3 + uses: actions/setup-python@v4 + with: + python-version: ${{ env.python-version }} + + - name: Install Maturin + run: pip3 install maturin + + - name: Build Python + working-directory: ./pyfinlib + run: maturin develop + publishNPM: name: Publish NPM runs-on: ubuntu-latest - needs: [ build ] # for ignoring bad builds + needs: [ buildWASM ] # for ignoring bad builds if: github.event_name == 'push' && github.ref == 'refs/heads/master' steps: - name: Checkout diff --git a/Cargo.lock b/Cargo.lock index 676577c..5e1017b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -259,7 +259,7 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "finlib" -version = "0.0.1" +version = "0.0.2" dependencies = [ "getrandom 0.2.15", "log", @@ -274,7 +274,7 @@ dependencies = [ [[package]] name = "finlib-ffi" -version = "0.0.1" +version = "0.0.2" dependencies = [ "cbindgen", "csbindgen", @@ -283,7 +283,7 @@ dependencies = [ [[package]] name = "finlib-wasm" -version = "0.0.1" +version = "0.0.2" dependencies = [ "console_error_panic_hook", "console_log", @@ -606,7 +606,7 @@ dependencies = [ [[package]] name = "pyfinlib" -version = "0.0.1" +version = "0.0.2" dependencies = [ "finlib", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 0867f5b..6b2dbbb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ default-members = [ ] [workspace.package] -version = "0.0.1" +version = "0.0.2" authors = ["sarsoo <andy@sarsoo.xyz>"] description = "Quant finance functions implemented in Rust" edition = "2021" diff --git a/finlib/src/ffi/mod.rs b/finlib/src/ffi/mod.rs new file mode 100644 index 0000000..a4a5a25 --- /dev/null +++ b/finlib/src/ffi/mod.rs @@ -0,0 +1,4 @@ +#[cfg(feature = "py")] +pub mod py; +#[cfg(feature = "wasm")] +pub mod wasm; \ No newline at end of file diff --git a/finlib/src/py/mod.rs b/finlib/src/ffi/py/mod.rs similarity index 100% rename from finlib/src/py/mod.rs rename to finlib/src/ffi/py/mod.rs diff --git a/finlib/src/py/portfolio.rs b/finlib/src/ffi/py/portfolio.rs similarity index 100% rename from finlib/src/py/portfolio.rs rename to finlib/src/ffi/py/portfolio.rs diff --git a/finlib/src/wasm/mod.rs b/finlib/src/ffi/wasm/mod.rs similarity index 100% rename from finlib/src/wasm/mod.rs rename to finlib/src/ffi/wasm/mod.rs diff --git a/finlib/src/wasm/portfolio.rs b/finlib/src/ffi/wasm/portfolio.rs similarity index 100% rename from finlib/src/wasm/portfolio.rs rename to finlib/src/ffi/wasm/portfolio.rs diff --git a/finlib/src/lib.rs b/finlib/src/lib.rs index 02693b1..ec12a32 100644 --- a/finlib/src/lib.rs +++ b/finlib/src/lib.rs @@ -2,7 +2,4 @@ pub mod interest; pub mod stats; pub mod util; pub mod risk; -#[cfg(feature = "py")] -pub mod py; -#[cfg(feature = "wasm")] -pub mod wasm; \ No newline at end of file +pub mod ffi; \ No newline at end of file