# 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/ApeWorX/ape-cairo",
"name": "ape-cairo",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<3.11",
"maintainer_email": "",
"keywords": "ethereum",
"author": "ApeWorX Ltd.",
"author_email": "admin@apeworx.io",
"download_url": "https://files.pythonhosted.org/packages/be/42/49ff4501c4c55b2dc80cb7f62b47d3910e921a03e2d4f06a58cbf3a9ea2f/ape-cairo-0.6.1.tar.gz",
"platform": null,
"description": "# Quick Start\n\nApe compiler plugin around [the Cairo language](https://github.com/starkware-libs/cairo-lang).\n\n## Dependencies\n\n- [python3](https://www.python.org/downloads) version 3.8 or greater, python3-dev\n- [Rust](https://www.rust-lang.org/)\n\n## Installation\n\n### via `pip`\n\nYou can install the latest release via [`pip`](https://pypi.org/project/pip/):\n\n```bash\npip install ape-cairo\n```\n\n### via `setuptools`\n\nYou can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:\n\n```bash\ngit clone https://github.com/ApeWorX/ape-cairo.git\ncd ape-cairo\npython3 setup.py install\n```\n\n## Quick Usage\n\nFirst, you will need to tell `ape-cairo` how to use the Cairo compiler.\nThere are two ways to do this:\n\n1. Configure your Cairo manifest path in your `ape-config.yaml`.\n2. Build or add Cairo compiler binaries to your $PATH.\n\nBoth options require cloning the Cairo compiler source code:\n\n```sh\ngit clone git@github.com:starkware-libs/cairo.git\ncd cairo\ngit fetch --all\ngit checkout <tag> # e.g. v1.0.0-alpha.6\n```\n\nTo do the first option, add the following to your `ape-config.yaml` file:\n\n```yaml\ncairo:\n manifest: /Users/home/path/to/cairo/Cargo.toml\n```\n\nNow, when compiling, Ape will use the command `cargo run --bin <BIN> --manifest-path <CAIRO-MANIFEST>`.\nTo do the second option instead, build the release binaries for your OS:\n\n```sh\ncargo build --release\n```\n\n**NOTE**: This requires being in the same directory as Cairo.\n\nAfter the build completes, add the target path to your global $PATH variable.\n(You may want to add this to your `.zshrc` / `.bashrc` file):\n\n```sh\nexport PATH=$PATH:$HOME/path/to/cairo/target/release\n```\n\nVerify you have `sierra-compile` in your `$PATH` by doing:\n\n```bash\nwhich sierra-compile\n```\n\n**WARN**: Note that when using Cairo-lang the python package, it will add conflicting binaries with the same name.\nYou will need to ensure you are using the correct binaries if you have `cairo-lang` the Python package installed.\n\n```shell\nwhich starknet-compile\n```\n\nAlternatively, the first approach avoids this problem.\n\n### Using the Compiler\n\nIn a project directory where there are `.cairo` files in your `contracts/` directory, run the `compile` command:\n\n```bash\nape compile\n```\n\nIt should create `ContractType` objects in your `.build/` folder containing the necessary Sierra code for contract declaration.\n\n## Development\n\nThis project is in development and should be considered a beta.\nThings might not be in their final state and breaking changes may occur.\nComments, questions, criticisms and pull requests are welcomed.\n\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "ape-cairo: A compiler plugin for the cairo programming language",
"version": "0.6.1",
"split_keywords": [
"ethereum"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b27bccf9fa024619351cfcfc819f3dcaddc65f6d5d65ec1ac2dfbacc95e98ec7",
"md5": "c10c5f86f6333a669d8470d9720209c3",
"sha256": "18a79481534cd39c626bb003052d7b25c769ae40bf299213eb7d34233217e45e"
},
"downloads": -1,
"filename": "ape_cairo-0.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c10c5f86f6333a669d8470d9720209c3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<3.11",
"size": 11391,
"upload_time": "2023-04-18T22:32:34",
"upload_time_iso_8601": "2023-04-18T22:32:34.557861Z",
"url": "https://files.pythonhosted.org/packages/b2/7b/ccf9fa024619351cfcfc819f3dcaddc65f6d5d65ec1ac2dfbacc95e98ec7/ape_cairo-0.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "be4249ff4501c4c55b2dc80cb7f62b47d3910e921a03e2d4f06a58cbf3a9ea2f",
"md5": "7bdddf37de8f78f7fb9c3d8867781131",
"sha256": "f6820045c0d70907f407433bab1812b44f7863a0cb4544469a2165643ee6b1db"
},
"downloads": -1,
"filename": "ape-cairo-0.6.1.tar.gz",
"has_sig": false,
"md5_digest": "7bdddf37de8f78f7fb9c3d8867781131",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<3.11",
"size": 20336,
"upload_time": "2023-04-18T22:32:36",
"upload_time_iso_8601": "2023-04-18T22:32:36.188092Z",
"url": "https://files.pythonhosted.org/packages/be/42/49ff4501c4c55b2dc80cb7f62b47d3910e921a03e2d4f06a58cbf3a9ea2f/ape-cairo-0.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-18 22:32:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "ApeWorX",
"github_project": "ape-cairo",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ape-cairo"
}