2019-02-06 08:17:16 -05:00
|
|
|
# Embedded Unit Converter
|
2019-02-01 08:41:54 -05:00
|
|
|
|
2019-10-30 10:37:01 -04:00
|
|
|
Embed a small bit of code that converts between units of measure, e.g.
|
2019-10-29 10:25:27 -04:00
|
|
|
Fahrenheit to Celsius.
|
2019-02-01 08:41:54 -05:00
|
|
|
|
2019-10-29 10:25:27 -04:00
|
|
|
An example of a Rust library that is embeddable in Python.
|
2019-02-01 08:41:54 -05:00
|
|
|
|
2019-10-29 10:25:27 -04:00
|
|
|
## Getting setup
|
2019-02-01 08:41:54 -05:00
|
|
|
|
|
|
|
Insure the following dependencies are in place:
|
|
|
|
|
2019-10-29 10:25:27 -04:00
|
|
|
* Rust v1.34+ (nightly)
|
|
|
|
* Install using `rustup toolchain install nightly`
|
2019-02-06 10:39:39 -05:00
|
|
|
* Python dependencies
|
2019-10-29 10:25:27 -04:00
|
|
|
* Python 3 Development headers `apt install python3-dev`
|
|
|
|
* pipenv `pip install --user pipenv`
|
2019-02-01 08:41:54 -05:00
|
|
|
|
2019-02-06 08:57:13 -05:00
|
|
|
## Running the Python example
|
|
|
|
|
|
|
|
1. Build the rust crate first: `cargo build`
|
2019-02-06 10:39:39 -05:00
|
|
|
1. Install dependencies and run in a virtualenv: `pipenv install && pipenv shell`
|
2019-10-29 10:41:01 -04:00
|
|
|
1. Create the Python package with: `maturin build`
|
2019-02-06 09:04:04 -05:00
|
|
|
1. Run the tests: `pytest test.py`
|
2019-02-06 08:57:13 -05:00
|
|
|
|
2019-02-01 08:41:54 -05:00
|
|
|
## Documentation
|
|
|
|
|
|
|
|
* [PyO3 Python - Rust bindings](https://pyo3.rs/master/get_started.html)
|