-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sketch out rust extension layout using maturin/PyO3
- Loading branch information
1 parent
19f84f5
commit 96ebdf5
Showing
9 changed files
with
489 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# This file is autogenerated by maturin v1.2.3 | ||
# To update, run | ||
# | ||
# maturin generate-ci github | ||
# | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
tags: | ||
- '*' | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
linux: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
- name: Build wheels | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: ${{ matrix.target }} | ||
args: --release --out dist --find-interpreter | ||
sccache: 'true' | ||
manylinux: auto | ||
- name: Upload wheels | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wheels | ||
path: dist | ||
|
||
windows: | ||
runs-on: windows-latest | ||
strategy: | ||
matrix: | ||
target: [x64, x86] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
architecture: ${{ matrix.target }} | ||
- name: Build wheels | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: ${{ matrix.target }} | ||
args: --release --out dist --find-interpreter | ||
sccache: 'true' | ||
- name: Upload wheels | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wheels | ||
path: dist | ||
|
||
macos: | ||
runs-on: macos-latest | ||
strategy: | ||
matrix: | ||
target: [x86_64, aarch64] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
- name: Build wheels | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: ${{ matrix.target }} | ||
args: --release --out dist --find-interpreter | ||
sccache: 'true' | ||
- name: Upload wheels | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wheels | ||
path: dist | ||
|
||
sdist: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build sdist | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
command: sdist | ||
args: --out dist | ||
- name: Upload sdist | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wheels | ||
path: dist | ||
|
||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
if: "startsWith(github.ref, 'refs/tags/')" | ||
needs: [linux, windows, macos, sdist] | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: wheels | ||
- name: Publish to PyPI | ||
uses: PyO3/maturin-action@v1 | ||
env: | ||
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | ||
with: | ||
command: upload | ||
args: --non-interactive --skip-existing * |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,10 @@ | |
build | ||
dist | ||
|
||
# rust | ||
target | ||
*.so | ||
|
||
docs/source/api/* | ||
|
||
# data | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,14 +76,37 @@ Clone this repository: | |
|
||
git clone [email protected]:tomalrussell/snkit.git | ||
|
||
Maybe set up a virtualenv or conda environment, as you wish. Then install `snkit` in editable | ||
mode, with development packages: | ||
Maybe set up a virtualenv or conda environment, as you wish. | ||
|
||
For example, using | ||
[`micromamba`](https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html) | ||
to create an environment with all dependencies: | ||
|
||
```bash | ||
micromamba create -n snkit python=3.11 \ | ||
"geopandas>=0.13" \ | ||
"shapely>=2.0" \ | ||
"networkx>=3.0" \ | ||
"maturin>=1.2,<2.0" \ | ||
pytest \ | ||
pytest-cov \ | ||
black \ | ||
nbstripout | ||
micromamba activate snkit | ||
``` | ||
|
||
For reference, [`maturin`](https://www.maturin.rs) is used to build the rust | ||
extension module `snkit.core`. The rust-Python bindings are created using | ||
[`PyO3`](https://pyo3.rs/). The project is currently laid out with the rust | ||
source code in `rust/src` and Python in `src/snkit`. | ||
|
||
Install `snkit` in editable mode, with development packages: | ||
|
||
pip install -e .[dev] | ||
maturin develop --extras=dev,networkx | ||
|
||
Run the tests: | ||
|
||
python -m pytest tests/ | ||
python -m pytest | ||
|
||
## Testimonials 💯 👍 😊 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,40 @@ | ||
[tool.pytest.ini_options] | ||
pythonpath = [ | ||
"src", | ||
[project] | ||
name = "snkit" | ||
description = "a spatial networks toolkit" | ||
dynamic = ["version"] | ||
readme = "README.md" | ||
authors = [{ name = "Tom Russell", email = "[email protected]" }] | ||
requires-python = ">=3.7" | ||
classifiers = [ | ||
"Programming Language :: Python", | ||
"Programming Language :: Rust", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
"Development Status :: 4 - Beta", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Topic :: Scientific/Engineering :: GIS", | ||
"Topic :: Utilities", | ||
] | ||
dependencies = ["geopandas>=0.13", "shapely>=2.0"] | ||
|
||
[project.optional-dependencies] | ||
"dev" = ["black", "nbstripout", "pytest", "pytest-cov"] | ||
"networkx" = ["networkx>=3.0"] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/tomalrussell/snkit" | ||
Documentation = "https://snkit.readthedocs.io/en/latest/" | ||
|
||
[build-system] | ||
requires = ["maturin>=1.2,<2.0"] | ||
build-backend = "maturin" | ||
|
||
[tool.maturin] | ||
features = ["pyo3/extension-module"] | ||
python-source = "src" | ||
module-name = "snkit.core" | ||
|
||
[tool.pytest.ini_options] | ||
pythonpath = ["src"] |
Oops, something went wrong.