Python interface for the newton_rootfinder crate
In order to generate a wheel valid for you computer, you need to:
- Install Rust
- Install a Python version and install maturin:
pip install maturin
- Switch to Rust nightly (this is due to the PyO3 dependency):
rustup default nightly
- Build the crate with
cargo build --release
(if it is the first build, an internet connexion is required to download dependencies from http://crates.io). If you are using macOS, check the nota bene. - Create the Python wheel by running
maturin build
. This build the wheel in thetarget/wheels
directory. Alternatively, you can usematurin develop
which also install it in your current Python environment.
N-B: If you are using macOS, you need to run the following command line: cargo rustc --release -- -C link-arg=-undefined -C link-arg=dynamic_lookup
. You can also edit your .cargo/config
file and add the following content:
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
- Don't hesitate the check maturin's documentation
- The file
./python/main.py
gives an example of using the newton-raphson solver. The model used is in./python/model.py
. It is assumed to be run from thepython
folder usingpython main.py
- Don't hesitate to check the newton_rootfinder crate documentation to know all the parameters you can set up. Only a subset of those is available in Python.