Metadata-Version: 2.1
Name: ape-cairo
Version: 0.6.1
Summary: ape-cairo: A compiler plugin for the cairo programming language
Home-page: https://github.com/ApeWorX/ape-cairo
Author: ApeWorX Ltd.
Author-email: admin@apeworx.io
License: Apache-2.0
Keywords: ethereum
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.8,<3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: eth-ape (<0.7,>=0.6.8)
Requires-Dist: ethpm-types
Provides-Extra: dev
Requires-Dist: pytest (<8,>=6.0) ; extra == 'dev'
Requires-Dist: pytest-xdist ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: hypothesis (<7.0,>=6.70) ; extra == 'dev'
Requires-Dist: black (>=23.3.0) ; extra == 'dev'
Requires-Dist: mypy (<1,>=0.991) ; extra == 'dev'
Requires-Dist: types-setuptools ; extra == 'dev'
Requires-Dist: flake8 (<7,>=6.0.0) ; extra == 'dev'
Requires-Dist: isort (<6,>=5.10.1) ; extra == 'dev'
Requires-Dist: mdformat (<0.8,>=0.7.16) ; extra == 'dev'
Requires-Dist: mdformat-gfm (<0.4,>=0.3.5) ; extra == 'dev'
Requires-Dist: mdformat-frontmatter (<0.5,>=0.4.1) ; extra == 'dev'
Requires-Dist: setuptools ; extra == 'dev'
Requires-Dist: wheel ; extra == 'dev'
Requires-Dist: twine ; extra == 'dev'
Requires-Dist: commitizen (<3,>=2.42) ; extra == 'dev'
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: pytest-watch ; extra == 'dev'
Requires-Dist: IPython ; extra == 'dev'
Requires-Dist: ipdb ; extra == 'dev'
Provides-Extra: lint
Requires-Dist: black (>=23.3.0) ; extra == 'lint'
Requires-Dist: mypy (<1,>=0.991) ; extra == 'lint'
Requires-Dist: types-setuptools ; extra == 'lint'
Requires-Dist: flake8 (<7,>=6.0.0) ; extra == 'lint'
Requires-Dist: isort (<6,>=5.10.1) ; extra == 'lint'
Requires-Dist: mdformat (<0.8,>=0.7.16) ; extra == 'lint'
Requires-Dist: mdformat-gfm (<0.4,>=0.3.5) ; extra == 'lint'
Requires-Dist: mdformat-frontmatter (<0.5,>=0.4.1) ; extra == 'lint'
Provides-Extra: release
Requires-Dist: setuptools ; extra == 'release'
Requires-Dist: wheel ; extra == 'release'
Requires-Dist: twine ; extra == 'release'
Provides-Extra: test
Requires-Dist: pytest (<8,>=6.0) ; extra == 'test'
Requires-Dist: pytest-xdist ; extra == 'test'
Requires-Dist: pytest-cov ; extra == 'test'
Requires-Dist: hypothesis (<7.0,>=6.70) ; extra == 'test'

# Quick Start

Ape compiler plugin around [the Cairo language](https://github.com/starkware-libs/cairo-lang).

## Dependencies

- [python3](https://www.python.org/downloads) version 3.8 or greater, python3-dev
- [Rust](https://www.rust-lang.org/)

## Installation

### via `pip`

You can install the latest release via [`pip`](https://pypi.org/project/pip/):

```bash
pip install ape-cairo
```

### via `setuptools`

You can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:

```bash
git clone https://github.com/ApeWorX/ape-cairo.git
cd ape-cairo
python3 setup.py install
```

## Quick Usage

First, you will need to tell `ape-cairo` how to use the Cairo compiler.
There are two ways to do this:

1. Configure your Cairo manifest path in your `ape-config.yaml`.
2. Build or add Cairo compiler binaries to your $PATH.

Both options require cloning the Cairo compiler source code:

```sh
git clone git@github.com:starkware-libs/cairo.git
cd cairo
git fetch --all
git checkout <tag>  # e.g. v1.0.0-alpha.6
```

To do the first option, add the following to your `ape-config.yaml` file:

```yaml
cairo:
  manifest: /Users/home/path/to/cairo/Cargo.toml
```

Now, when compiling, Ape will use the command `cargo run --bin <BIN> --manifest-path <CAIRO-MANIFEST>`.
To do the second option instead, build the release binaries for your OS:

```sh
cargo build --release
```

**NOTE**: This requires being in the same directory as Cairo.

After the build completes, add the target path to your global $PATH variable.
(You may want to add this to your `.zshrc` / `.bashrc` file):

```sh
export PATH=$PATH:$HOME/path/to/cairo/target/release
```

Verify you have `sierra-compile` in your `$PATH` by doing:

```bash
which sierra-compile
```

**WARN**: Note that when using Cairo-lang the python package, it will add conflicting binaries with the same name.
You will need to ensure you are using the correct binaries if you have `cairo-lang` the Python package installed.

```shell
which starknet-compile
```

Alternatively, the first approach avoids this problem.

### Using the Compiler

In a project directory where there are `.cairo` files in your `contracts/` directory, run the `compile` command:

```bash
ape compile
```

It should create `ContractType` objects in your `.build/` folder containing the necessary Sierra code for contract declaration.

## Development

This project is in development and should be considered a beta.
Things might not be in their final state and breaking changes may occur.
Comments, questions, criticisms and pull requests are welcomed.


