Skip to content

Commit

Permalink
Merge Python wrapper crate into main crate
Browse files Browse the repository at this point in the history
  • Loading branch information
cberner committed Feb 22, 2020
1 parent f8b3ccd commit 6eeeb67
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 405 deletions.
5 changes: 5 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.x86_64-apple-darwin]
rustc-cdylib-link-arg = [
"-undefined",
"dynamic_lookup",
]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
**/__pycache__

.idea/
16 changes: 4 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,18 @@ matrix:
script:
- make test

- name: Run CPython wrapper linter
language: rust
rust: stable
install:
[]
before_script:
- cargo install cargo-deny
- rustup component add rustfmt
script:
- make -C python lint

- name: Run CPython wrapper tests
language: rust
rust: nightly
install:
[]
before_script:
- cargo install cargo-deny
- rustup component add rustfmt
- rustup component add clippy
- sudo apt update && sudo apt install python3 python3-pip python3-dev python3-venv
- pip3 install --upgrade pip
- pip3 install maturin
- python3 -m venv venv
script:
- source venv/bin/activate && make -C python test
- source venv/bin/activate && make test_py
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ version = "1.2.0"
edition = "2018"
authors = ["Christopher Berner <[email protected]>"]

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
serde = {version = "1.0.102", features=["std", "derive"]}
pyo3 = {version = "0.8.4", features=["extension-module"], optional = true }

[dev-dependencies]
criterion = "0.3"
Expand Down Expand Up @@ -37,3 +41,4 @@ debug = true

[features]
benchmarking = []
python = ["pyo3"]
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,18 @@ bench: pre

profile:
RUSTFLAGS='-Cforce-frame-pointers' cargo bench --no-run --features benchmarking

build_py: pre
maturin build --cargo-extra-args="--features python"

release_py: pre
maturin build --release --cargo-extra-args="--features python"

publish_py: test_py
maturin publish --cargo-extra-args="--features python"

install_py: pre
maturin develop --cargo-extra-args="--features python"

test_py: install_py
python3 -m unittest discover
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ Note that the additional classes exported by the `benchmarking` feature flag are
crate's public API. Breaking changes to those classes may occur without warning. The flag is only provided
so that internal classes can be used in this crate's benchmarks.

## Python bindings

The Python bindings are generated using [pyo3](https://github.com/PyO3/pyo3).
Rust 1.37.0-nightly or higher is required for building [pyo3](https://github.com/PyO3/pyo3) projects.
```
$ rustup install nightly
$ rustup override set nightly
```

Some operating systems require additional packages to be installed.
```
$ sudo apt install python3-dev
```

[maturin](https://github.com/PyO3/maturin) is recommended for building the Python bindings in this crate.
```
$ pip install maturin
$ maturin build
```

Alternatively, refer to the [Building and Distribution section](https://pyo3.rs/v0.8.5/building_and_distribution.html) in the [pyo3 user guide](https://pyo3.rs/v0.8.5/).

## License

Licensed under
Expand Down
File renamed without changes.
5 changes: 0 additions & 5 deletions python/.cargo/config

This file was deleted.

1 change: 0 additions & 1 deletion python/.gitignore

This file was deleted.

Loading

0 comments on commit 6eeeb67

Please sign in to comment.