diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 015b897..86631fc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,21 +13,26 @@ jobs: - uses: actions/checkout@v3 with: submodules: "recursive" + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Run sccache stat for check before + shell: bash + run: ${SCCACHE_PATH} --show-stats - uses: actions-rs/toolchain@v1 with: toolchain: stable - name: cargo + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" run: | sudo apt-get update -y sudo apt-get install -y nasm cargo doc --no-deps cargo fmt --check cargo test --release - - uses: PyO3/maturin-action@v1 - with: - command: build - args: --release - working-directory: crates/sophus_pyo3 - + - name: Run sccache stat for check after + shell: bash + run: ${SCCACHE_PATH} --show-stats diff --git a/.github/workflows/py_wheels.yml b/.github/workflows/py_wheels.yml new file mode 100644 index 0000000..0f07919 --- /dev/null +++ b/.github/workflows/py_wheels.yml @@ -0,0 +1,122 @@ +# This file is autogenerated by maturin v1.5.0 +# To update, run +# +# maturin generate-ci github +# +name: py_wheels + +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] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist + working-directory: crates/sophus_pyo3 + sccache: 'true' + manylinux: auto + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-${{ matrix.target }} + path: crates/sophus_pyo3/dist + + windows: + runs-on: windows-latest + strategy: + matrix: + target: [x64, x86] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + architecture: ${{ matrix.target }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist + working-directory: crates/sophus_pyo3 + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-windows-${{ matrix.target }} + path: crates/sophus_pyo3/dist + + macos: + runs-on: macos-latest + strategy: + matrix: + target: [x86_64, aarch64] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist + working-directory: crates/sophus_pyo3 + sccache: 'true' + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-macos-${{ matrix.target }} + path: crates/sophus_pyo3/dist + + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + working-directory: crates/sophus_pyo3 + - name: Upload sdist + uses: actions/upload-artifact@v4 + with: + name: wheels-sdist + path: crates/sophus_pyo3/dist + + release: + name: Release + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + needs: [linux, windows, macos, sdist] + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + - name: Publish to PyPI + uses: PyO3/maturin-action@v1 + with: + command: upload + args: --non-interactive --skip-existing wheels-*/* diff --git a/Cargo.toml b/Cargo.toml index dc437f7..583fc64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,13 +24,13 @@ repository = "https://github.com/farm-ng/sophus-rs/" version = "0.4.0" [workspace.dependencies] -sophus = {path = "crates/sophus"} -sophus_calculus = {path = "crates/sophus_calculus"} -sophus_image = {path = "crates/sophus_image"} -sophus_lie = {path = "crates/sophus_lie"} -sophus_opt = {path = "crates/sophus_opt"} -sophus_sensor = {path = "crates/sophus_sensor"} -sophus_tensor = {path = "crates/sophus_tensor"} +sophus = {path = "crates/sophus", version = "0.4.0"} +sophus_calculus = {path = "crates/sophus_calculus", version = "0.4.0"} +sophus_image = {path = "crates/sophus_image", version = "0.4.0"} +sophus_lie = {path = "crates/sophus_lie", version = "0.4.0"} +sophus_opt = {path = "crates/sophus_opt", version = "0.4.0"} +sophus_sensor = {path = "crates/sophus_sensor", version = "0.4.0"} +sophus_tensor = {path = "crates/sophus_tensor", version = "0.4.0"} approx = {version = "0.5.1"} as-any = "0.3.1" diff --git a/crates/sophus_pyo3/src/lib.rs b/crates/sophus_pyo3/src/lib.rs index d862971..435759c 100644 --- a/crates/sophus_pyo3/src/lib.rs +++ b/crates/sophus_pyo3/src/lib.rs @@ -11,7 +11,7 @@ use numpy::pyo3::prelude::*; /// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to /// import the module. #[pymodule] -fn sophus(_py: Python, m: &PyModule) -> PyResult<()> { +fn sophus_pyo3(_py: Python, m: &PyModule) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?;