Skip to content

Commit ca7fe26

Browse files
committed
Initial commit
0 parents  commit ca7fe26

17 files changed

+748
-0
lines changed

.github/workflows/python.yaml

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Test & Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
sdist:
16+
name: Build sdist
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- uses: actions/setup-python@v2
21+
name: Install Python
22+
with:
23+
python-version: '3.7'
24+
- name: Install deps
25+
run: pip install -U maturin
26+
- name: Build sdist
27+
run: maturin build --release --strip
28+
- uses: actions/upload-artifact@v2
29+
with:
30+
path: ./target/wheels/*.tar.gz
31+
name: dist
32+
build_wheels:
33+
name: Build wheels on ${{ matrix.os }} / Python ${{ matrix.python }}
34+
runs-on: ${{ matrix.os }}
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
os: [ubuntu-latest, windows-latest, macos-latest]
39+
# For CPython only build 3.7 since we use the abi3 limited API
40+
# For PyPy, build all versions
41+
python: ["3.7", "pypy-3.7", "pypy-3.8"]
42+
include:
43+
- python: "pypy-3.7"
44+
cibw_build: "pp37*"
45+
- python: "pypy-3.8"
46+
cibw_build: "pp38*"
47+
- python: "3.7"
48+
cibw_build: "cp37-*"
49+
steps:
50+
- uses: actions/checkout@v2
51+
- uses: actions/setup-python@v2
52+
with:
53+
python-version: ${{ matrix.python }}
54+
- uses: actions-rs/toolchain@v1
55+
if: runner.os != 'Linux'
56+
with:
57+
toolchain: stable
58+
profile: minimal
59+
- name: Set up QEMU
60+
if: runner.os == 'Linux'
61+
uses: docker/setup-qemu-action@v1
62+
with:
63+
platforms: all
64+
- name: Install cibuildwheel
65+
run: |
66+
python -m pip install cibuildwheel
67+
- name: Build wheels
68+
run: |
69+
python -m cibuildwheel --output-dir wheelhouse
70+
env:
71+
CIBW_BEFORE_BUILD: "pip install -r requirements-dev.txt"
72+
CIBW_BEFORE_TEST: "pip install -r requirements-dev.txt"
73+
CIBW_TEST_COMMAND: "pytest {project}/test_routrie.py"
74+
# Install curl on manylinux_2 images (others have it) and then install cargo and rust
75+
CIBW_BEFORE_ALL_LINUX: "((apt-get update && apt-get install curl || true) && (curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable)) || apk add rust cargo"
76+
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"
77+
CIBW_BUILD: ${{ matrix.cibw_build }}
78+
CIBW_SKIP: "*-win32*"
79+
CIBW_ENVIRONMENT_LINUX: 'PATH="$PATH:$HOME/.cargo/bin"'
80+
# Cross compile on MacOS and Linux
81+
CIBW_ARCHS_MACOS: "auto universal2 arm64"
82+
CIBW_ARCHS_LINUX: "auto aarch64"
83+
- uses: actions/upload-artifact@v2
84+
with:
85+
name: dist
86+
path: ./wheelhouse/*.whl
87+
lint:
88+
runs-on: ubuntu-latest
89+
strategy:
90+
matrix:
91+
# Lint on earliest and latest
92+
python: ["3.7", "3.x"]
93+
steps:
94+
- uses: actions/checkout@v2
95+
- name: Set up Python
96+
uses: actions/setup-python@v2
97+
with:
98+
python-version: '3.x'
99+
- name: Install Rust toolchain
100+
uses: actions-rs/toolchain@v1
101+
with:
102+
toolchain: stable
103+
profile: minimal
104+
default: true
105+
- name: Lint
106+
run: |
107+
make lint
108+
release:
109+
name: Release
110+
runs-on: ubuntu-latest
111+
if: ${{ github.ref == 'refs/heads/main' }}
112+
needs:
113+
- sdist
114+
- build_wheels
115+
- lint
116+
steps:
117+
- uses: actions/download-artifact@v2
118+
with:
119+
name: dist
120+
- uses: actions/setup-python@v2
121+
with:
122+
python-version: "3.x"
123+
- name: Publish to PyPi
124+
env:
125+
TWINE_USERNAME: __token__
126+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
127+
run: |
128+
pip install --upgrade twine pip
129+
twine upload --skip-existing *

.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
3+
!/.gitignore
4+
!/src
5+
!/Cargo.toml
6+
!/Cargo.lock
7+
!/pyproject.toml
8+
!/python
9+
!/test_routrie.py
10+
!/bench.ipynb
11+
!/requirements-dev.txt
12+
!/requirements-bench.txt
13+
!/.pre-commit-config.yaml
14+
!/Makefile
15+
!/README.md
16+
!/.github
17+
!/LICENSE.txt
18+
19+
__pycache__
20+
*.so

.pre-commit-config.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
files: ^python/.*|^tests/.*|^src/.*
2+
repos:
3+
- repo: https://github.com/ambv/black
4+
rev: 21.11b1
5+
hooks:
6+
- id: black
7+
- repo: local
8+
hooks:
9+
- id: cargo-fmt
10+
name: cargo-fmt
11+
entry: cargo fmt
12+
language: system
13+
types: [rust]
14+
pass_filenames: false
15+
- id: cargo-clippy
16+
name: cargo-clippy
17+
entry: cargo clippy
18+
language: system
19+
types: [rust]
20+
pass_filenames: false
21+
- repo: https://gitlab.com/pycqa/flake8
22+
rev: 3.9.2
23+
hooks:
24+
- id: flake8
25+
args: ["--max-line-length=88"]
26+
- repo: https://github.com/pre-commit/mirrors-mypy
27+
rev: v0.910-1
28+
hooks:
29+
- id: mypy
30+
- repo: https://github.com/pre-commit/pre-commit-hooks
31+
rev: v4.0.1
32+
hooks:
33+
- id: end-of-file-fixer
34+
- id: trailing-whitespace
35+
- repo: https://github.com/pycqa/isort
36+
rev: 5.10.1
37+
hooks:
38+
- id: isort
39+
name: isort (python)

0 commit comments

Comments
 (0)