Skip to content

Commit 46ccfff

Browse files
authored
migrate to maturin for pyd4 build (#103)
1 parent 729ed9d commit 46ccfff

File tree

6 files changed

+398
-117
lines changed

6 files changed

+398
-117
lines changed
Lines changed: 208 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,223 @@
1-
name: Build pyd4
1+
# This file is autogenerated by maturin v1.8.1
2+
# To update, run
3+
#
4+
# maturin generate-ci github --pytest
5+
#
6+
name: pyd4 CI
27

38
on:
49
push:
5-
branches: [master]
10+
branches:
11+
- main
12+
- master
13+
tags:
14+
- '*'
615
pull_request:
7-
branches: [master]
16+
workflow_dispatch:
17+
18+
permissions:
19+
contents: read
820

921
jobs:
10-
build-and-test:
22+
linux:
1123
runs-on: ubuntu-latest
1224
steps:
1325
- uses: actions/checkout@v4
14-
15-
- name: Set up Rust
16-
uses: actions-rs/toolchain@v1
26+
- uses: actions/setup-python@v5
1727
with:
18-
toolchain: stable
19-
profile: minimal
28+
python-version: '3.12'
29+
- uses: dtolnay/rust-toolchain@stable
30+
- name: Build wheels
31+
uses: PyO3/maturin-action@v1
32+
with:
33+
target: x86_64
34+
args: --release --out dist --find-interpreter -m ./pyd4/Cargo.toml
35+
# - name: Upload wheels
36+
# uses: actions/upload-artifact@v4
37+
# with:
38+
# name: wheels-linux-${{ matrix.platform.target }}
39+
# path: dist
40+
- name: pytest
41+
shell: bash
42+
run: |
43+
set -e
44+
python3 -m venv .venv
45+
source .venv/bin/activate
46+
pip install pyd4 --find-links dist --force-reinstall
47+
pip install pytest
48+
pytest
49+
2050

21-
- name: Install UV
22-
uses: astral-sh/setup-uv@v3
51+
# musllinux:
52+
# runs-on: ${{ matrix.platform.runner }}
53+
# strategy:
54+
# matrix:
55+
# platform:
56+
# - runner: ubuntu-22.04
57+
# target: x86_64
58+
# - runner: ubuntu-22.04
59+
# target: x86
60+
# - runner: ubuntu-22.04
61+
# target: aarch64
62+
# - runner: ubuntu-22.04
63+
# target: armv7
64+
# steps:
65+
# - uses: actions/checkout@v4
66+
# - uses: actions/setup-python@v5
67+
# with:
68+
# python-version: 3.x
69+
# - name: Build wheels
70+
# uses: PyO3/maturin-action@v1
71+
# with:
72+
# target: ${{ matrix.platform.target }}
73+
# args: --release --out dist --find-interpreter
74+
# sccache: 'true'
75+
# manylinux: musllinux_1_2
76+
# - name: Upload wheels
77+
# uses: actions/upload-artifact@v4
78+
# with:
79+
# name: wheels-musllinux-${{ matrix.platform.target }}
80+
# path: dist
81+
# - name: pytest
82+
# if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
83+
# uses: addnab/docker-run-action@v3
84+
# with:
85+
# image: alpine:latest
86+
# options: -v ${{ github.workspace }}:/io -w /io
87+
# run: |
88+
# set -e
89+
# apk add py3-pip py3-virtualenv
90+
# python3 -m virtualenv .venv
91+
# source .venv/bin/activate
92+
# pip install pyd4 --no-index --find-links dist --force-reinstall
93+
# pip install pytest
94+
# pytest
95+
# - name: pytest
96+
# if: ${{ !startsWith(matrix.platform.target, 'x86') }}
97+
# uses: uraimo/run-on-arch-action@v2
98+
# with:
99+
# arch: ${{ matrix.platform.target }}
100+
# distro: alpine_latest
101+
# githubToken: ${{ github.token }}
102+
# install: |
103+
# apk add py3-virtualenv
104+
# run: |
105+
# set -e
106+
# python3 -m virtualenv .venv
107+
# source .venv/bin/activate
108+
# pip install pytest
109+
# pip install pyd4 --find-links dist --force-reinstall
110+
# pytest
23111

24-
- name: Set up Python
25-
uses: actions/setup-python@v5
26-
with:
27-
python-version-file: "pyd4/pyproject.toml"
112+
# windows:
113+
# runs-on: ${{ matrix.platform.runner }}
114+
# strategy:
115+
# matrix:
116+
# platform:
117+
# - runner: windows-latest
118+
# target: x64
119+
# - runner: windows-latest
120+
# target: x86
121+
# steps:
122+
# - uses: actions/checkout@v4
123+
# - uses: actions/setup-python@v5
124+
# with:
125+
# python-version: 3.x
126+
# architecture: ${{ matrix.platform.target }}
127+
# - name: Build wheels
128+
# uses: PyO3/maturin-action@v1
129+
# with:
130+
# target: ${{ matrix.platform.target }}
131+
# args: --release --out dist --find-interpreter
132+
# sccache: 'true'
133+
# - name: Upload wheels
134+
# uses: actions/upload-artifact@v4
135+
# with:
136+
# name: wheels-windows-${{ matrix.platform.target }}
137+
# path: dist
138+
# - name: pytest
139+
# if: ${{ !startsWith(matrix.platform.target, 'aarch64') }}
140+
# shell: bash
141+
# run: |
142+
# set -e
143+
# python3 -m venv .venv
144+
# source .venv/Scripts/activate
145+
# pip install pyd4 --find-links dist --force-reinstall
146+
# pip install pytest
147+
# pytest
28148

29-
- name: Install project
30-
run: |
31-
cd pyd4
32-
uv sync --all-extras --dev
149+
# macos:
150+
# runs-on: ${{ matrix.platform.runner }}
151+
# strategy:
152+
# matrix:
153+
# platform:
154+
# - runner: macos-13
155+
# target: x86_64
156+
# - runner: macos-14
157+
# target: aarch64
158+
# steps:
159+
# - uses: actions/checkout@v4
160+
# - uses: actions/setup-python@v5
161+
# with:
162+
# python-version: 3.x
163+
# - name: Build wheels
164+
# uses: PyO3/maturin-action@v1
165+
# with:
166+
# target: ${{ matrix.platform.target }}
167+
# args: --release --out dist --find-interpreter
168+
# sccache: 'true'
169+
# - name: Upload wheels
170+
# uses: actions/upload-artifact@v4
171+
# with:
172+
# name: wheels-macos-${{ matrix.platform.target }}
173+
# path: dist
174+
# - name: pytest
175+
# run: |
176+
# set -e
177+
# python3 -m venv .venv
178+
# source .venv/bin/activate
179+
# pip install pyd4 --find-links dist --force-reinstall
180+
# pip install pytest
181+
# pytest
33182

34-
- name: Build
35-
run: |
36-
cd pyd4
37-
uv build
183+
# sdist:
184+
# runs-on: ubuntu-latest
185+
# steps:
186+
# - uses: actions/checkout@v4
187+
# - name: Build sdist
188+
# uses: PyO3/maturin-action@v1
189+
# with:
190+
# command: sdist
191+
# args: --out dist
192+
# - name: Upload sdist
193+
# uses: actions/upload-artifact@v4
194+
# with:
195+
# name: wheels-sdist
196+
# path: dist
38197

39-
- name: Test
40-
run: |
41-
cd pyd4
42-
uv run pytest
198+
# release:
199+
# name: Release
200+
# runs-on: ubuntu-latest
201+
# if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
202+
# needs: [linux, musllinux, windows, macos, sdist]
203+
# permissions:
204+
# # Use to sign the release artifacts
205+
# id-token: write
206+
# # Used to upload release artifacts
207+
# contents: write
208+
# # Used to generate artifact attestation
209+
# attestations: write
210+
# steps:
211+
# - uses: actions/download-artifact@v4
212+
# - name: Generate artifact attestation
213+
# uses: actions/attest-build-provenance@v1
214+
# with:
215+
# subject-path: 'wheels-*/*'
216+
# - name: Publish to PyPI
217+
# if: ${{ startsWith(github.ref, 'refs/tags/') }}
218+
# uses: PyO3/maturin-action@v1
219+
# env:
220+
# MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
221+
# with:
222+
# command: upload
223+
# args: --non-interactive --skip-existing wheels-*/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ pyd4/*.egg-info/**
4444
pyd4/build/**
4545
pyd4/**/__pycache__/**
4646
.ipynb*
47+
dist

pyd4/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ env_logger = "0.9.0"
1212

1313
[lib]
1414
crate-type = ["cdylib"]
15-
name = "pyd4"
16-
path = "src/lib.rs"
15+
name = "_pyd4"
16+
path = "src/lib.rs"
17+
18+
[features]
19+
extension-module = ["pyo3/extension-module"]
20+
default = ["extension-module"]

pyd4/pyproject.toml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[build-system]
2-
requires = ["setuptools", "setuptools-rust", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["maturin>=1,<2"]
3+
build-backend = "maturin"
44

55
[project]
66
name = "pyd4"
7-
version = "0.3.6.2"
8-
requires-python = ">=3.12"
7+
version = "0.3.10"
8+
requires-python = ">=3.10"
99
description = "Python binding for D4 file format"
10-
dependencies = ["numpy>=2.2.2"]
10+
dependencies = ["numpy>1.24.4"]
1111
readme = "README.md"
1212
classifiers = [
1313
"License :: OSI Approved :: MIT License",
@@ -19,15 +19,10 @@ classifiers = [
1919
"Operating System :: MacOS :: MacOS X",
2020
]
2121

22-
[tool.setuptools.packages]
23-
find = { where = ["pyd4"] }
22+
[tool.maturin]
23+
python-source = "python"
24+
module-name = "pyd4._pyd4" # Points to Rust
2425

25-
[[tool.setuptools-rust.ext-modules]]
26-
target = "pyd4"
27-
path = "Cargo.toml"
28-
binding = "PyO3"
2926

3027
[dependency-groups]
31-
dev = [
32-
"pytest>=8.3.4",
33-
]
28+
dev = ["pytest>=8.3.4", "maturin>=1,<2"]

0 commit comments

Comments
 (0)