Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .copier-answers.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: d814faa
_commit: 8ac03b9
_src_path: https://github.com/python-project-templates/base.git
add_docs: true
add_extension: cpp
Expand Down
60 changes: 45 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,20 @@ permissions:

jobs:
build:
runs-on: ${{ matrix.os }}
name: build (${{ matrix.platform.name }}-${{ matrix.python.version }})
runs-on: ${{ matrix.platform.os }}

strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
platform:
- name: ubuntu-latest
os: ubuntu-latest
- name: ubuntu-24.04-arm
os: ubuntu-24.04-arm
- name: macos-latest
os: macos-latest
- name: windows-latest
os: windows-latest
python:
- version: "3.11"
cibuildwheel: "cp311"
Expand All @@ -40,6 +49,19 @@ jobs:
- version: "3.13"
cibuildwheel: "cp313"
primary: false
include:
- target: native
dist_path: dist
- platform:
name: pyodide
os: ubuntu-latest
python:
version: "3.14"
cibuildwheel: "cp314"
primary: false
target: pyodide
dist_path: dist/pyodide


steps:
- name: Checkout
Expand All @@ -60,38 +82,46 @@ jobs:

- name: Install dependencies
run: make develop
if: matrix.target == 'native'

- name: Lint
run: make lint
if: matrix.os == 'ubuntu-latest' && matrix.python.primary
if: matrix.platform.name == 'ubuntu-latest' && matrix.python.primary

- name: Checks
run: make checks
if: matrix.os == 'ubuntu-latest' && matrix.python.primary
if: matrix.platform.name == 'ubuntu-latest' && matrix.python.primary

- name: Test
run: make coverage
if: matrix.target == 'native'

- name: Build and test Pyodide wheel
run: make test-pyodide
if: matrix.target == 'pyodide'

- name: Upload test results (Python)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: test-results-${{ matrix.os }}-${{ matrix.python.version }}
name: test-results-${{ matrix.platform.name }}-${{ matrix.python.version }}
path: junit.xml
if: matrix.os == 'ubuntu-latest' && matrix.python.primary
if: matrix.platform.name == 'ubuntu-latest' && matrix.python.primary

- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@d0a4676d0e0b938bc201470d88276b7c74c712b3 # v2.24.0
with:
files: '**/junit.xml'
if: matrix.os == 'ubuntu-latest' && matrix.python.primary
if: matrix.platform.name == 'ubuntu-latest' && matrix.python.primary

- name: Upload coverage
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
if: matrix.target == 'native'

- name: Install build dependencies
run: pip install cibuildwheel
if: matrix.target == 'native'

- name: Build distributions (Linux x86_64)
run: |
Expand All @@ -103,7 +133,7 @@ jobs:
CIBW_BUILD: "${{ matrix.python.cibuildwheel }}-manylinux*"
CIBW_ARCHS_LINUX: native
CIBW_BUILD_VERBOSITY: 3
if: matrix.os == 'ubuntu-latest'
if: matrix.platform.name == 'ubuntu-latest'

- name: Build distributions (Linux ARM64)
run: |
Expand All @@ -114,7 +144,7 @@ jobs:
CIBW_BUILD: "${{ matrix.python.cibuildwheel }}-manylinux*"
CIBW_ARCHS_LINUX: native
CIBW_BUILD_VERBOSITY: 3
if: matrix.os == 'ubuntu-24.04-arm'
if: matrix.platform.name == 'ubuntu-24.04-arm'

- name: Build distributions (macOS)
run: |
Expand All @@ -123,30 +153,30 @@ jobs:
env:
CIBW_BUILD: "${{ matrix.python.cibuildwheel }}-macos*"
CIBW_BUILD_VERBOSITY: 3
if: matrix.os == 'macos-latest'
if: matrix.platform.name == 'macos-latest'

- name: Build distributions (Windows)
run: |
if (Test-Path dist) { Remove-Item dist -Recurse -Force }
make dist-py-wheel
env:
CIBW_BUILD: "${{ matrix.python.cibuildwheel }}-win_amd64"
if: matrix.os == 'windows-latest'
if: matrix.platform.name == 'windows-latest'

- name: Test wheel
uses: actions-ext/python/test-wheel@6e1b91a408ea89f49bc8aff8724f83826f7b5446
with:
module: python_template_cpp
if: runner.os == 'Linux'
if: matrix.target == 'native' && runner.os == 'Linux'

- name: Test source distribution
uses: actions-ext/python/test-sdist@6e1b91a408ea89f49bc8aff8724f83826f7b5446
with:
module: python_template_cpp
if: matrix.os == 'ubuntu-latest'
if: matrix.platform.name == 'ubuntu-latest'

- name: Upload distributions
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist-${{ matrix.os }}-${{ matrix.python.version }}
path: dist
name: dist-${{ matrix.platform.name }}-${{ matrix.python.version }}
path: ${{ matrix.dist_path }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ python_template_cpp/labextension

# Emscripten SDK (locally installed)
emsdk
.pyodide_build/


# Mac
.DS_Store
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ tests-py: test-py
coverage-py: ## run python tests and collect test coverage
python -m pytest -v python_template_cpp/tests --cov=python_template_cpp --cov-report term-missing --cov-report xml

.PHONY: test coverage tests
.PHONY: test test-pyodide coverage tests
test: test-py ## run all tests

test-pyodide: ## build and test the Python package in Pyodide
uvx --from cibuildwheel==4.2.0 cibuildwheel --only cp314-pyodide_wasm32 --output-dir dist/pyodide .

coverage: coverage-py ## run all tests and collect test coverage

# alias
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
requires = [
"hatchling",
"hatch-cpp",
"hatch-cpp>=0.5.0",
"pybind11",
]
build-backend = "hatchling.build"
Expand Down Expand Up @@ -39,7 +39,7 @@ develop = [
"check-dist",
"cibuildwheel",
"codespell",
"hatch-cpp",
"hatch-cpp>=0.5.0",
"hatchling",
"mdformat",
"mdformat-tables>=1",
Expand Down Expand Up @@ -93,6 +93,10 @@ archs = "arm64"
archs = "AMD64"
skip = "*win32 *arm_64"

[tool.cibuildwheel.pyodide]
test-command = "python -m pytest -vvv --pyargs python_template_cpp.tests"
test-extras = []
test-requires = ["pytest"]
[tool.coverage.run]
branch = true
omit = [
Expand Down
1 change: 1 addition & 0 deletions python_template_cpp/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading