Skip to content

Commit

Permalink
Replacing maturin with setuptools-rust
Browse files Browse the repository at this point in the history
Maturin really works out of the box locally, but we are having troubles finding a consistent way of distributing the wheels in a place that can be downloaded easily for any distribution (mac or alpine etc) without having to mangle dockerfiles too much
  • Loading branch information
ThiagoCodecov committed Oct 28, 2020
1 parent 37e9b8d commit ce54b45
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include Cargo.toml
recursive-include src *
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Rust Service to be called from inside python

This is some rust code that is meant to be installed as a python wheel on the repository and used

It uses [pyo3](https://pyo3.rs) as the binding and [maturin](https://github.com/PyO3/maturin) as the tool that turns the rust code into python
It uses [pyo3](https://pyo3.rs) as the binding and [setuptools-rust](https://github.com/PyO3/setuptools-rust) as the tool that turns the rust code into python

We hope it provides a new level of speed to the CPU-bound parts of the code
16 changes: 16 additions & 0 deletions build-wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -ex

curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y
export PATH="$HOME/.cargo/bin:$PATH"

cd /io

for PYBIN in /opt/python/cp{35,36,37,38,39}*/bin; do
"${PYBIN}/pip" install -U setuptools wheel setuptools-rust
"${PYBIN}/python" setup.py bdist_wheel
done

for whl in dist/*.whl; do
auditwheel repair "$whl" -w dist/
done
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools-rust"]
1 change: 1 addition & 0 deletions ribs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from rustypole import *
11 changes: 11 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from setuptools import setup
from setuptools_rust import Binding, RustExtension

setup(
name="ribs",
version="1.0",
rust_extensions=[RustExtension("ribs.rustypole", binding=Binding.PyO3)],
packages=["ribs"],
# rust extensions are not zip safe, just like C-extensions.
zip_safe=False,
)

0 comments on commit ce54b45

Please sign in to comment.