diff --git a/.copier-answers.yml b/.copier-answers.yml index ff00235..6963e37 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,10 +1,10 @@ # Changes here will be overwritten by Copier -_commit: f8b63c7 +_commit: 0b16729 _src_path: . add_extension: rust email: 3105306+timkpaine@users.noreply.github.com github: python-project-templates project_description: A Rust-Python project template project_name: rust template -python_version_primary: '3.11' +python_version_primary: '3.9' team: Python Project Template Authors diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2050074..8fd9525 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,3 @@ - name: Build Status on: @@ -31,7 +30,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.11"] + python-version: ["3.9"] steps: - uses: actions/checkout@v4 @@ -49,12 +48,26 @@ jobs: toolchain: stable components: clippy, rustfmt + - name: Setup Rust cache + uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.os }} + + - name: Setup rust targets (MacOS) + run: rustup target add aarch64-apple-darwin + if: matrix.os == 'macos-latest' + + - name: Setup rust targets (Windows) + run: | + rustup toolchain install stable-i686-pc-windows-msvc + rustup target add i686-pc-windows-msvc + if: matrix.os == 'windows-latest' + - name: Install dependencies run: make develop - name: Lint run: make lint - if: ${{ matrix.os == 'ubuntu-latest' }} - name: Checks run: make checks @@ -65,7 +78,6 @@ jobs: - name: Test run: make coverage - if: ${{ matrix.os == 'ubuntu-latest' }} - name: Upload test results (Python) uses: actions/upload-artifact@v4 @@ -85,6 +97,20 @@ jobs: uses: codecov/codecov-action@v4 - name: Make dist - run: make dist + run: | + make dist-rust + make dist-py-sdist + make dist-py-wheel + make dist-check if: ${{ matrix.os == 'ubuntu-latest' }} + - name: Make dist + run: | + make dist-py-wheel + make dist-check + if: ${{ matrix.os != 'ubuntu-latest' }} + + - uses: actions/upload-artifact@v4 + with: + name: wheels + path: dist diff --git a/Cargo.lock b/Cargo.lock index 5494bbe..b630f4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,9 +61,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "portable-atomic" @@ -82,9 +82,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "831e8e819a138c36e212f3af3fd9eeffed6bf1510a805af35b0edee5ffa59433" +checksum = "15ee168e30649f7f234c3d49ef5a7a6cbf5134289bc46c29ff3155fa3221c225" dependencies = [ "cfg-if", "indoc", @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8730e591b14492a8945cdff32f089250b05f5accecf74aeddf9e8272ce1fa8" +checksum = "e61cef80755fe9e46bb8a0b8f20752ca7676dcc07a5277d8b7768c6172e529b3" dependencies = [ "once_cell", "target-lexicon", @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e97e919d2df92eb88ca80a037969f44e5e70356559654962cbb3316d00300c6" +checksum = "67ce096073ec5405f5ee2b8b31f03a68e02aa10d5d4f565eca04acc41931fa1c" dependencies = [ "libc", "pyo3-build-config", @@ -121,9 +121,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb57983022ad41f9e683a599f2fd13c3664d7063a3ac5714cae4b7bee7d3f206" +checksum = "2440c6d12bc8f3ae39f1e775266fa5122fd0c8891ce7520fa6048e683ad3de28" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -133,9 +133,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec480c0c51ddec81019531705acac51bcdbeae563557c982aa8263bb96880372" +checksum = "1be962f0e06da8f8465729ea2cb71a416d2257dff56cbe40a70d3e62a93ae5d1" dependencies = [ "heck", "proc-macro2", diff --git a/Makefile b/Makefile index 67998a7..044ba02 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ develop-rust: develop: develop-rust develop-py ## setup project for development -.PHONY: build-py build-rust build +.PHONY: build-py build-rust build dev build-py: maturin build @@ -41,10 +41,11 @@ lint-py: ## run python linter with ruff python -m ruff check rust_template python -m ruff format --check rust_template -lint-rust: ## run the rust linter +lint-rust: ## run rust linter make -C rust lint lint: lint-rust lint-py ## run project linters + # alias lints: lint @@ -57,6 +58,7 @@ fix-rust: ## fix rust formatting make -C rust fix fix: fix-rust fix-py ## run project autoformatters + # alias format: fix @@ -79,26 +81,30 @@ annotate: ## run python type annotation checks with mypy ######### # TESTS # ######### -.PHONY: test test-py coverage-py tests - +.PHONY: test-py tests-py coverage-py test-py: ## run python tests python -m pytest -v rust_template/tests --junitxml=junit.xml + # alias tests-py: test-py coverage-py: ## run python tests and collect test coverage python -m pytest -v rust_template/tests --junitxml=junit.xml --cov=rust_template --cov-branch --cov-fail-under=50 --cov-report term-missing --cov-report xml +.PHONY: test-rust tests-rust coverage-rust test-rust: ## run rust tests make -C rust test + # alias tests-rust: test-rust coverage-rust: ## run rust tests and collect test coverage make -C rust coverage +.PHONY: test coverage tests test: test-py test-rust ## run all tests coverage: coverage-py coverage-rust ## run all tests and collect test coverage + # alias tests: test @@ -122,18 +128,21 @@ major: ## bump a major version ######## # DIST # ######## -.PHONY: dist dist-build dist-sdist dist-local-wheel publish +.PHONY: dist-py-wheel dist-py-sdist dist-rust dist-check dist publish + +dist-py-wheel: # build python wheel + python -m cibuildwheel --output-dir dist -dist-build-py: # build python dists - python -m build -w -s +dist-py-sdist: # build python sdist + python -m build --sdist -o dist -dist-build-rust: # build rust dists +dist-rust: # build rust dists make -C rust dist dist-check: ## run python dist checker with twine python -m twine check dist/* -dist: clean build dist-build-rust dist-build-py dist-check ## build all dists +dist: clean build dist-rust dist-py-wheel dist-py-sdist dist-check ## build all dists publish: dist # publish python assets diff --git a/pyproject.toml b/pyproject.toml index b7cd466..cb3cbaa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ develop = [ "build", "bump-my-version", "check-manifest", + "cibuildwheel", "maturin>=1,<2", "pytest", "pytest-cov", @@ -80,6 +81,26 @@ ignore = [ "rust/README.md", ] +[tool.cibuildwheel] +before-build = "rustup show" +build = "cp39-*" +test-command = "pytest -vvv {project}/rust_template/tests" +test-requires = ["pytest", "pytest-cov", "pytest-sugar", "pytest-xdist"] + +[tool.cibuildwheel.linux] +before-build = "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y && rustup show" +environment = {PATH="$HOME/.cargo/bin:$PATH", CARGO_TERM_COLOR="always"} +skip = "*i686 musllinux*" +manylinux-x86_64-image = "manylinux_2_28" + +[tool.cibuildwheel.macos] +archs = "arm64" + +[tool.cibuildwheel.windows] +environment = {PATH="$UserProfile\\.cargo\bin;$PATH"} +archs = "AMD64 *win32" +skip = "*arm_64" + [tool.pytest.ini_options] asyncio_mode = "strict" testpaths = "rust_template/tests"