Skip to content

Commit 844103b

Browse files
authored
Merge pull request py-econometrics#878 from py-econometrics/rust
Implement Rust Backend
2 parents f374fee + ec613c6 commit 844103b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+10020
-7071
lines changed
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
# This file is autogenerated by maturin v1.8.6
2+
# To update, run
3+
#
4+
# maturin generate-ci github --platform all
5+
#
6+
name: CI
7+
8+
on:
9+
push:
10+
branches:
11+
- master
12+
tags:
13+
- '*'
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
linux:
21+
runs-on: ${{ matrix.platform.runner }}
22+
strategy:
23+
matrix:
24+
platform:
25+
- runner: ubuntu-22.04
26+
target: x86_64
27+
- runner: ubuntu-22.04
28+
target: x86
29+
- runner: ubuntu-22.04
30+
target: aarch64
31+
- runner: ubuntu-22.04
32+
target: armv7
33+
- runner: ubuntu-22.04
34+
target: s390x
35+
- runner: ubuntu-22.04
36+
target: ppc64le
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: actions/setup-python@v5
40+
with:
41+
python-version: 3.x
42+
- name: Build wheels
43+
uses: PyO3/maturin-action@v1
44+
with:
45+
target: ${{ matrix.platform.target }}
46+
args: --release --out dist --find-interpreter
47+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
48+
manylinux: auto
49+
- name: Upload wheels
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: wheels-linux-${{ matrix.platform.target }}
53+
path: dist
54+
55+
musllinux:
56+
runs-on: ${{ matrix.platform.runner }}
57+
strategy:
58+
matrix:
59+
platform:
60+
- runner: ubuntu-22.04
61+
target: x86_64
62+
- runner: ubuntu-22.04
63+
target: x86
64+
- runner: ubuntu-22.04
65+
target: aarch64
66+
- runner: ubuntu-22.04
67+
target: armv7
68+
steps:
69+
- uses: actions/checkout@v4
70+
- uses: actions/setup-python@v5
71+
with:
72+
python-version: 3.x
73+
- name: Build wheels
74+
uses: PyO3/maturin-action@v1
75+
with:
76+
target: ${{ matrix.platform.target }}
77+
args: --release --out dist --find-interpreter
78+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
79+
manylinux: musllinux_1_2
80+
- name: Upload wheels
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: wheels-musllinux-${{ matrix.platform.target }}
84+
path: dist
85+
86+
windows:
87+
runs-on: ${{ matrix.platform.runner }}
88+
strategy:
89+
matrix:
90+
platform:
91+
- runner: windows-latest
92+
target: x64
93+
- runner: windows-latest
94+
target: x86
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: actions/setup-python@v5
98+
with:
99+
python-version: 3.x
100+
architecture: ${{ matrix.platform.target }}
101+
- name: Build wheels
102+
uses: PyO3/maturin-action@v1
103+
with:
104+
target: ${{ matrix.platform.target }}
105+
args: --release --out dist --find-interpreter
106+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
107+
- name: Upload wheels
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: wheels-windows-${{ matrix.platform.target }}
111+
path: dist
112+
113+
macos:
114+
runs-on: ${{ matrix.platform.runner }}
115+
strategy:
116+
matrix:
117+
platform:
118+
- runner: macos-13
119+
target: x86_64
120+
- runner: macos-14
121+
target: aarch64
122+
steps:
123+
- uses: actions/checkout@v4
124+
- uses: actions/setup-python@v5
125+
with:
126+
python-version: 3.x
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: ${{ !startsWith(github.ref, 'refs/tags/') }}
133+
- name: Upload wheels
134+
uses: actions/upload-artifact@v4
135+
with:
136+
name: wheels-macos-${{ matrix.platform.target }}
137+
path: dist
138+
139+
emscripten:
140+
runs-on: ${{ matrix.platform.runner }}
141+
strategy:
142+
matrix:
143+
platform:
144+
- runner: ubuntu-22.04
145+
target: wasm32-unknown-emscripten
146+
steps:
147+
- uses: actions/checkout@v4
148+
- run: pip install pyodide-build
149+
- name: Get Emscripten and Python version info
150+
shell: bash
151+
run: |
152+
echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV
153+
echo PYTHON_VERSION=$(pyodide config get python_version | cut -d '.' -f 1-2) >> $GITHUB_ENV
154+
pip uninstall -y pyodide-build
155+
- uses: mymindstorm/setup-emsdk@v12
156+
with:
157+
version: ${{ env.EMSCRIPTEN_VERSION }}
158+
actions-cache-folder: emsdk-cache
159+
- uses: actions/setup-python@v5
160+
with:
161+
python-version: ${{ env.PYTHON_VERSION }}
162+
- run: pip install pyodide-build
163+
- name: Build wheels
164+
uses: PyO3/maturin-action@v1
165+
with:
166+
target: ${{ matrix.platform.target }}
167+
args: --release --out dist -i ${{ env.PYTHON_VERSION }}
168+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
169+
rust-toolchain: nightly
170+
- name: Upload wheels
171+
uses: actions/upload-artifact@v4
172+
with:
173+
name: wasm-wheels
174+
path: dist
175+
176+
sdist:
177+
runs-on: ubuntu-latest
178+
steps:
179+
- uses: actions/checkout@v4
180+
- name: Build sdist
181+
uses: PyO3/maturin-action@v1
182+
with:
183+
command: sdist
184+
args: --out dist
185+
- name: Upload sdist
186+
uses: actions/upload-artifact@v4
187+
with:
188+
name: wheels-sdist
189+
path: dist
190+
191+
release:
192+
name: Release
193+
runs-on: ubuntu-latest
194+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
195+
needs: [linux, musllinux, windows, macos, emscripten, sdist]
196+
permissions:
197+
# Use to sign the release artifacts
198+
id-token: write
199+
# Used to upload release artifacts
200+
contents: write
201+
# Used to generate artifact attestation
202+
attestations: write
203+
steps:
204+
- uses: actions/download-artifact@v4
205+
- name: Generate artifact attestation
206+
uses: actions/attest-build-provenance@v2
207+
with:
208+
subject-path: 'wheels-*/*'
209+
- name: Publish to PyPI
210+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
211+
uses: PyO3/maturin-action@v1
212+
env:
213+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
214+
with:
215+
command: upload
216+
args: --non-interactive --skip-existing wheels-*/*
217+
- name: Upload to GitHub Release
218+
uses: softprops/action-gh-release@v1
219+
with:
220+
files: |
221+
wasm-wheels/*.whl
222+
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}

.github/workflows/ci-tests.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ jobs:
4848
mkdir -p $R_LIB_PATH
4949
Rscript -e ".libPaths('$R_LIB_PATH'); install.packages(c('did2s', 'wildrwolf', 'ivDiag'), lib='/home/runner/work/pyfixest/pyfixest/.pixi/envs/dev/lib/R/library', repos = c('https://cran.rstudio.com', 'https://s3alfisc.r-universe.dev'))"
5050
Rscript -e ".libPaths('$R_LIB_PATH'); install.packages('ritest', lib='/home/runner/work/pyfixest/pyfixest/.pixi/envs/dev/lib/R/library', repos = c('https://grantmcdermott.r-universe.dev'))"
51+
52+
53+
- name: Compile Rust extension (no wheel)
54+
run: |
55+
pixi r maturin-develop
56+
5157
- name: Run 'regular' tests
5258
run: |
5359
pixi run tests-regular

.github/workflows/extended_tests.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ jobs:
4646
mkdir -p $R_LIB_PATH
4747
Rscript -e ".libPaths('$R_LIB_PATH'); install.packages(c('did2s', 'wildrwolf', 'ivDiag'), lib='/home/runner/work/pyfixest/pyfixest/.pixi/envs/dev/lib/R/library', repos = c('https://cran.rstudio.com', 'https://s3alfisc.r-universe.dev'))"
4848
Rscript -e ".libPaths('$R_LIB_PATH'); install.packages('ritest', lib='/home/runner/work/pyfixest/pyfixest/.pixi/envs/dev/lib/R/library', repos = c('https://grantmcdermott.r-universe.dev'))"
49+
50+
- name: Compile Rust extension (no wheel)
51+
run: |
52+
pixi r maturin-develop
53+
4954
- name: Run long tests with coverage
5055
run: pixi run tests-extended
5156

.github/workflows/publish-to-pypi.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@ tests/.coverage
3030
.pixi
3131
*.egg-info
3232
pyfixest/did/data/mpdata.csv
33+
target
34+
# Ignore compiled Python extensions from Rust (PyO3/maturin/pyo3-pack)
35+
*.so
36+
*.pyd
37+
*.dll
38+
*.dylib

0 commit comments

Comments
 (0)