Skip to content

Commit

Permalink
Migrate to compiling on Rust stable
Browse files Browse the repository at this point in the history
- Clean up CI. No need to install nightly rust anymore
- Migrate to latest PyO3
  • Loading branch information
nickbabcock committed Jan 2, 2021
1 parent 0cdeaa7 commit d43bfc5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 34 deletions.
24 changes: 3 additions & 21 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@ on:

jobs:
lint:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: "clippy, rustfmt"

- name: Lint with rustfmt
uses: actions-rs/cargo@v1
with:
Expand All @@ -37,7 +30,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8]
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-20.04, macos-latest, windows-latest]

steps:
- name: Checkout
Expand All @@ -53,11 +46,6 @@ jobs:
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Build Python package
run: poetry run maturin develop --release
Expand All @@ -73,20 +61,14 @@ jobs:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8]
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-20.04, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v1

- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ boxcars = "0.8.6"
serde_json = "1.0.52"

[dependencies.pyo3]
version = "0.9.2"
features = ["extension-module", "python3"]
version = "0.13.0"
features = ["extension-module"]

[lib]
name = "boxcars_py"
Expand Down
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ MATURIN := maturin
PYTHON := python

.PHONY: build
build: nightly dev-packages
build: dev-packages
poetry run $(MATURIN) build --interpreter $(PYTHON)

.PHONY: build-release
build-release: nightly dev-packages
build-release: dev-packages
poetry run $(MATURIN) build --release --interpreter $(PYTHON)

.PHONY: nightly
nightly:
rustup override set nightly

.PHONY: install
install: nightly dev-packages
install: dev-packages
poetry run $(MATURIN) develop --release

.PHONY: publish
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ replay = parse_replay(buf)
## Building from source

__Requirements__
- Rust Nightly. Minium supported version: 1.42.0-nightly 2020-01-21
- Rust.
- [poetry](https://pypi.org/project/poetry/)

```
Expand Down
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ fn boxcars_py(_py: Python, m: &PyModule) -> PyResult<()> {
}

fn to_py_error<E: std::error::Error>(e: E) -> PyErr {
PyErr::new::<exceptions::Exception, _>(format!("{}", e))
PyErr::new::<exceptions::PyException, _>(format!("{}", e))
}

fn convert_to_py(py: Python, value: &Value) -> PyObject {
match value {
Value::Null => py.None(),
Value::Bool(b) => PyObject::from_py(*b, py),
Value::Bool(b) => b.into_py(py),
Value::Number(n) => match n {
n if n.is_u64() => n.as_u64().unwrap().into_py(py),
n if n.is_i64() => n.as_i64().unwrap().into_py(py),
Expand Down

0 comments on commit d43bfc5

Please sign in to comment.