aditink / algebraic_simplification_cesar

Egg Heuristics for algebraic simplification used by the CESAR tool.
GNU General Public License v2.0
2 stars 3 forks source link

Add Python bindings for light and aggressive simplification functions #15

Closed zhufangu closed 3 months ago

zhufangu commented 3 months ago

Before you begin, ensure you have the following installed:

Step 1: Setting Up Environment Create a Virtual Environment:

python3 -m venv .env  
source .env/bin/activate

Step 2: Installing Maturin

pip install maturin

Inside the directory, now run maturin init. This will generate the new package source. When given the choice of bindings to use, select pyo3 bindings:

$ maturin init
βœ” 🀷 Which kind of bindings to use?
  πŸ“– Documentation: https://maturin.rs/bindings.html Β· pyo3
  ✨ Done! Initialized project /your/path

Step 3: Building and Installing the Python Module This will build the package and install it into the Python virtualenv previously created and activated. The package is then ready to be used from python:

maturin develop

An example output would be:

πŸ“¦ Including license file "/path/to/project/LICENSE"
πŸ”— Found pyo3 bindings
🐍 Found CPython 3.12 at /path/to/project/.env/bin/python
πŸ“‘ Using build options features from pyproject.toml
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.21s
πŸ“¦ Built wheel for CPython 3.12 to /var/folders/.../algebraic_simplification_cesar-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
✏️  Setting installed package as editable
πŸ›  Installed algebraic_simplification_cesar-0.1.0

Step 4: Using the Python Module Open a Python Shell:

python

Import and Use the Module:

import simplify
simplify.aggressive_simplify("formula","assumption")

References For more detailed information on using PyO3, refer to the official PyO3 guide.