From 9f21e99c691df414cc7bfb4161cd92b249062e92 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Tue, 29 Oct 2019 10:25:27 -0400 Subject: [PATCH] Update example for PyCon Canada talk. --- Cargo.toml | 3 +- Pipfile | 1 + Pipfile.lock | 103 +++++++++++++++++++++++++++++++++++++------------ README.md | 27 +++++-------- rust-toolchain | 1 + 5 files changed, 92 insertions(+), 43 deletions(-) create mode 100644 rust-toolchain diff --git a/Cargo.toml b/Cargo.toml index 804dccb..8d12c61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,10 +3,11 @@ name = "embedded-unit-converter" version = "0.1.0" authors = ["Dorian Pula "] edition = "2018" +license = "Apache-2.0" [lib] name = "unit_converter" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.6.0-alpha.2", features = ["extension-module"] } +pyo3 = { version = "0.8", features = ["extension-module"] } diff --git a/Pipfile b/Pipfile index 7ca8a99..2c0172f 100644 --- a/Pipfile +++ b/Pipfile @@ -4,6 +4,7 @@ url = "https://pypi.org/simple" verify_ssl = true [dev-packages] +maturin = "*" [packages] pyo3-pack = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 9a5d283..feb9df3 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "0630251fe5bf105722ab858c5ac0549f000628fbbfa4255c36a7fcfef9ed3559" + "sha256": "f446b2fd462f856414a21e7626c27a9736f94dca7ec455bfc5c575699f366703" }, "pipfile-spec": 6, "requires": { @@ -25,51 +25,72 @@ }, "attrs": { "hashes": [ - "sha256:10cbf6e27dbce8c30807caf056c8eb50917e0eaafe86347671b57254006c3e69", - "sha256:ca4be454458f9dec299268d472aaa5a11f67a4ff70093396e1ceae9c76cf4bbb" + "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c", + "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72" ], - "version": "==18.2.0" + "version": "==19.3.0" + }, + "importlib-metadata": { + "hashes": [ + "sha256:aa18d7378b00b40847790e7c27e11673d7fed219354109d0e7b9e5b25dc3ad26", + "sha256:d5f18a79777f3aa179c145737780282e27b508fc8fd688cb17c7a813e8bd39af" + ], + "markers": "python_version < '3.8'", + "version": "==0.23" }, "more-itertools": { "hashes": [ - "sha256:38a936c0a6d98a38bcc2d03fdaaedaba9f412879461dd2ceff8d37564d6522e4", - "sha256:c0a5785b1109a6bd7fac76d6837fd1feca158e54e521ccd2ae8bfe393cc9d4fc", - "sha256:fe7a7cae1ccb57d33952113ff4fa1bc5f879963600ed74918f1236e212ee50b9" + "sha256:409cd48d4db7052af495b09dec721011634af3753ae1ef92d2b32f73a745f832", + "sha256:92b8c4b06dac4f0611c0729b2f2ede52b2e1bac1ab48f089c7ddc12e26bb60c4" ], - "version": "==5.0.0" + "version": "==7.2.0" + }, + "packaging": { + "hashes": [ + "sha256:28b924174df7a2fa32c1953825ff29c61e2f5e082343165438812f00d3a7fc47", + "sha256:d9551545c6d761f3def1677baf08ab2a3ca17c56879e70fecba2fc4dde4ed108" + ], + "version": "==19.2" }, "pluggy": { "hashes": [ - "sha256:8ddc32f03971bfdf900a81961a48ccf2fb677cf7715108f85295c67405798616", - "sha256:980710797ff6a041e9a73a5787804f848996ecaa6f8a1b1e08224a5894f2074a" + "sha256:0db4b7601aae1d35b4a033282da476845aa19185c1e6964b25cf324b5e4ec3e6", + "sha256:fa5fa1622fa6dd5c030e9cad086fa19ef6a0cf6d7a2d12318e10cb49d6d68f34" ], - "version": "==0.8.1" + "version": "==0.13.0" }, "py": { "hashes": [ - "sha256:bf92637198836372b520efcba9e020c330123be8ce527e535d185ed4b6f45694", - "sha256:e76826342cefe3c3d5f7e8ee4316b80d1dd8a300781612ddbc765c17ba25a6c6" + "sha256:64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa", + "sha256:dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53" ], - "version": "==1.7.0" + "version": "==1.8.0" }, "pyo3-pack": { "hashes": [ - "sha256:19250198b465b2b872ec3ef362b925ae8af1963119783b1d38f7d61a4c56faf8", - "sha256:623a1f8159a26385d24ec63653ed21bf73d49f1ecdbd141314e799b905e35f49", - "sha256:756987d0de960d33ac23e409134821d142cbba4cae6ffd6ec4fb63a67cef6305", - "sha256:768d883a36dad98dbac6f7b44730b33686f3b0f71d4ebf2b6beb3884fbb70015", - "sha256:c14d82499896804b49c4d7175402db7e0dff165575d9797370ae75cf7221b62a" + "sha256:3b9b34ba43ad009c3b4ad3f508d0d364891f47242f47a604b4e5ea68dfcab32d", + "sha256:61b8a7e1b2c83517e8ae59d9a3ec2819e9e78e42aedfb11bd2aa885a87d21464", + "sha256:6360527be7a06e414542a9bb90db4f68beb24f774a3d5c0bcf8e1b729ef3e375", + "sha256:d787a96f9927dab6e70e31a7c51778d4837504f96789fa7d87217c8da324d993", + "sha256:e3804376cb5c2b51c49834539b0fb7373afbd142b7ff53846a011a01460e4c19" ], "index": "pypi", - "version": "==0.4.2" + "version": "==0.6.1" + }, + "pyparsing": { + "hashes": [ + "sha256:6f98a7b9397e206d78cc01df10131398f1c8b8510a2f4d97d9abd82e1aacdd80", + "sha256:d9338df12903bbf5d65a0e4e87c2161968b10d2e489652bb47001d82a9b028b4" + ], + "version": "==2.4.2" }, "pytest": { "hashes": [ - "sha256:65aeaa77ae87c7fc95de56285282546cfa9c886dc8e5dc78313db1c25e21bc07", - "sha256:6ac6d467d9f053e95aaacd79f831dbecfe730f419c6c7022cb316b365cd9199d" + "sha256:27abc3fef618a01bebb1f0d6d303d2816a99aa87a5968ebc32fe971be91eb1e6", + "sha256:58cee9e09242937e136dbb3dab466116ba20d6b7828c7620f23947f37eb4dae4" ], "index": "pypi", - "version": "==4.2.0" + "version": "==5.2.2" }, "six": { "hashes": [ @@ -77,7 +98,41 @@ "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" ], "version": "==1.12.0" + }, + "wcwidth": { + "hashes": [ + "sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e", + "sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c" + ], + "version": "==0.1.7" + }, + "zipp": { + "hashes": [ + "sha256:3718b1cbcd963c7d4c5511a8240812904164b7f381b647143a89d3b98f9bcd8e", + "sha256:f06903e9f1f43b12d371004b4ac7b06ab39a44adc747266928ae6debfa7b3335" + ], + "version": "==0.6.0" } }, - "develop": {} + "develop": { + "maturin": { + "hashes": [ + "sha256:0e58532b845aad5d1a1df9dd6ef56456d63b737e4a3a30e8572447fbc23d151f", + "sha256:4e2f73f97d2f030da42a2758e56e95ce2491afd9a080e70b78b088128145af87", + "sha256:90efda63af6c565a986d1e050673e033cbefc3c9b2996fa2fdf9e6d94d5bd179", + "sha256:9eecde82ee37772764d6237b7784912241d0b93292f72ff29a921f33842691ca", + "sha256:a435b280afcba7a1ca7203a60b198d8f93d874db0ffed13ee537c5066160b429", + "sha256:ab75ad31257d2238673bde7d402c2e7608e37a8042350ca7fd51f70382a1a638" + ], + "index": "pypi", + "version": "==0.7.6" + }, + "toml": { + "hashes": [ + "sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c", + "sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e" + ], + "version": "==0.10.0" + } + } } diff --git a/README.md b/README.md index d8ad4a8..5301a14 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,27 @@ # Embedded Unit Converter -Embed a small bit of code that converts between units of measure, e.g. Fahrenheit to Celsius. +Embed a small bit of code that converts between units of measure, e.g. +Fahrenheit to Celsius. -An example of a Rust library that is embeddable in Python and WebAssembly. +An example of a Rust library that is embeddable in Python. -## Getting setup +## Getting setup Insure the following dependencies are in place: -* Rust v1.32+ (nightly) - * Install using `rustup toolchain install nightly` - * Set default toolchain `rustup default nightly` +* Rust v1.34+ (nightly) + * Install using `rustup toolchain install nightly` * Python dependencies - * Python 3 Development headers `apt install python3-dev` - * pipenv `pip install --user pipenv` -* WebAssembly - * [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) - * npm + * Python 3 Development headers `apt install python3-dev` + * pipenv `pip install --user pipenv` ## Running the Python example 1. Build the rust crate first: `cargo build` 1. Install dependencies and run in a virtualenv: `pipenv install && pipenv shell` -1. Create the Python package with: `pyo3 develop` +1. Create the Python package with: `manturin build` 1. Run the tests: `pytest test.py` -## Running the WebAssembly example - -TODO: - ## Documentation * [PyO3 Python - Rust bindings](https://pyo3.rs/master/get_started.html) -* [Setting up WebAssembly](https://www.hellorust.com/setup/wasm-target/) -* [Rust WASM book](https://rustwasm.github.io/book/introduction.html) diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..bf867e0 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly