Skip to main content

No project description provided

Project description

cairo-rs-py

rust codecov

cairo-rs-py adds Python bindings to the cairo-rs Cairo VM.

Dependencies

  • Rust and Cargo
  • Pyenv and Python 3.9
  • GMP
  • make

Using cairo-rs-py

To setup the Python environment, and install necessary Python libraries, run make deps.

Finally, install into the python environment with maturin develop --release.

After that, you can access the cairo-rs VM from Python code. As an example, after compiling the program array_sum into cairo_programs/array_sum.json, you can run it with the VM using:

import cairo_rs_py

with open(f"cairo_programs/array_sum.json") as file:
    runner = cairo_rs_py.CairoRunner(file.read(), "main", "all", False)
    runner.cairo_run(True)

Testing

To run the test suite:

make full-test

Script to try out cairo-rs-py

The build_envs.sh script will build two Python virtual environments:

  • cairo-lang containing a pristine install of cairo-lang==0.10.3;
  • cairo-rs-py containing a patched install of cairo-lang==0.10.3 that uses cairo-rs-py as dependency. It will also install the required dependencies automatically in Debian-based distributions, CentOs, Fedora and OSX. If you use another OS you can check how to install them manually below.

To run the script:

./scripts/build_envs.sh

Both virtualenvs will be created under the /scripts directory.

To actually use any of the implementations you would have to activate the environment you want. For example to use the cairo-rs-py integration you need to run:

source activate scripts/cairo-rs-py/bin/activate

After activating the cairo-rs-py virtualenv you can try out any Cairo project and it will use cairo-rs.

Note that the script assumes you have a Rust toolchain, Python 3.9 and the venv program installed.

How to manually install the script dependencies

cairo-lang requires the gmp library to build. You can install it on Debian-based GNU/Linux distributions with:

sudo apt install -y libgmp3-dev

In Mac you can use Homebrew:

brew install gmp

In Mac you'll also need to tell the script where to find the gmp lib:

export CFLAGS=-I/opt/homebrew/opt/gmp/include LDFLAGS=-L/opt/homebrew/opt/gmp/lib
sh build_envs.sh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cairo_rs_py-0.1.0.tar.gz (96.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cairo_rs_py-0.1.0-cp39-cp39-manylinux_2_34_x86_64.whl (998.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

cairo_rs_py-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file cairo_rs_py-0.1.0.tar.gz.

File metadata

  • Download URL: cairo_rs_py-0.1.0.tar.gz
  • Upload date:
  • Size: 96.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.14.1

File hashes

Hashes for cairo_rs_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 363d11bcc5184c97a9643e440cb0a6a18443720a5c179b63a08946c7c928dea3
MD5 bb14d5da5a75020172a0ea6edf2c9530
BLAKE2b-256 a338f30486c3ccbdd4c5c25bf6b023cef6d3080d538f9b79c427ec7080f9039d

See more details on using hashes here.

File details

Details for the file cairo_rs_py-0.1.0-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cairo_rs_py-0.1.0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 35c6d478a859972f6703957af3b9c9d34912a6725255d0bdf5e8c9c5de26d342
MD5 2020871bca79228369a6bf08a4151432
BLAKE2b-256 f618296524aba2b912ee4e80c20bf00e0b4722e9b44121e23877dc1ddc9352e0

See more details on using hashes here.

File details

Details for the file cairo_rs_py-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cairo_rs_py-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3cd9b9c20fb694356fa145303af2d8b4569b09b4137791c21a4a068814c057ba
MD5 ffc53e0f8890e2d5ac187053fb31da14
BLAKE2b-256 0d73b943b13ee6c08089953de6447cc02569de1c5f9d127f3f202a2e75ad4468

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page