ape-vyper


Nameape-vyper JSON
Version 0.8.9 PyPI version JSON
download
home_pagehttps://github.com/ApeWorX/ape-vyper
SummaryPlugin for Ape Ethereum Framework for compiling Vyper contracts
upload_time2025-02-05 20:52:23
maintainerNone
docs_urlNone
authorApeWorX Ltd.
requires_python<4,>=3.10
licenseApache-2.0
keywords ethereum
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Quick Start

Ape compiler plugin around [VVM](https://github.com/vyperlang/vvm)

## Dependencies

- [python3](https://www.python.org/downloads) version 3.10 up to 3.12.

## Installation

### via `pip`

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

```bash
pip install ape-vyper
```

### 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-vyper.git
cd ape-vyper
python3 setup.py install
```

## Quick Usage

First, place Vyper contract source files (files with extension `.vy`) in your Ape project's contracts folder.
An example Vyper contract can be found [here](https://vyper.readthedocs.io/en/stable/vyper-by-example.html).
Then, from your root Ape project folder, run the command:

```bash
ape compile
```

The `.vy` files in your project will compile into `ContractTypes` that you can deploy and interact with in Ape.

### Contract Flattening

For ease of publishing, validation, and some other cases it's sometimes useful to "flatten" your contract into a single file.
This combines your contract and any imported interfaces together in a way the compiler can understand.
You can do so with a command like this:

```bash
ape vyper flatten contracts/MyContract.vy build/MyContractFlattened.vy
```

> [!WARNING]
> This feature is experimental. Please [report any bugs](https://github.com/ApeWorX/ape-solidity/issues/new?assignees=&labels=bug&projects=&template=bug.md) you find when trying it out.

### Compiler Version

By default, the `ape-vyper` plugin uses version pragma for version specification.
However, you can also configure the version directly in your `pyproject.toml` file:

```toml
[tool.vyper.version]
version = "0.3.7"
```

### EVM Versioning

By default, `ape-vyper` will use whatever version of EVM rules are set as default in the compiler version that gets used,
or based on what the `#pragma evm-version ...` pragma comment specifies (available post-`v0.3.10`).
Sometimes, you might want to use a different version, such as deploying on Arbitrum or Optimism where new opcodes are not supported yet.
If you want to require a different version of EVM rules to use in the configuration of the compiler, set it in your `ape-config.yaml` like this:

```toml
[tool.ape.vyper]
evm_version = "paris"
```

**NOTE**: The config value chosen will not override if a pragma is set in a contract.

### Interfaces

You can not compile interface source files directly.
Thus, you must place interface files in a directory named `interfaces` in your `contracts_folder` e.g. `contracts/interfaces/IFace.vy`.
Then, these files can be imported in other `.vy` sources files via:

```python
import interfaces.IFace as IFace
```

Alternatively, use JSON interfaces from dependency contract types by listing them under the `import_remapping` key:

```toml
[[tool.ape.dependencies]]
name = "VyperVoting"
github = "vyperlang/vyper"
contracts_folder = "examples/voting/"
version = "v0.3.8"

[tool.ape.vyper]
import_remapping = ["voting=VyperVoting@v0.3.8"]
```

Import the voting contract types like this:

```python
# @version 0.3.10

import voting.ballot as ballot
```

### Decimals

To use decimals on Vyper 0.4, use the following config:

```toml
[tool.ape.vyper]
enable_decimals = true
```

### Pragmas

Ape-Vyper supports Vyper 0.3.10's [new pragma formats](https://github.com/vyperlang/vyper/pull/3493)

#### Version Pragma

```python
#pragma version 0.3.10
```

#### EVM Version Pragma

```python
#pragma evm-version paris
```

#### Optimization Pragma

```python
#pragma optimize codesize
```

### VVM CLI

You can install versions of Vyper using the `ape vyper vvm` CLI tools.
List installed versions using:

```shell
ape vyper vvm list
```

To list the available Vyper versions, do:

```shell
ape vyper vvm list --available
```

Install more versions using the command:

```shell
ape vyper vvm install 0.3.7 0.3.10
```

### Custom Output Format

To customize Vyper's output format (like the native `-f` flag), you can configure the output format:
For example, to only get the ABI, do:

```toml
[tool.ape.vyper]
output_format = ["abi"]
```

To do this using the CLI only (adhoc), use the following command:

```shell
ape compile --config-override '{"vyper": {"output_format": ["abi"]}}'
```

#### Solc JSON Format

`ape-vyper` supports the `socl_json` format.
To use this format, configure `ape-vyper` like:

```toml
[tool.ape.vyper]
output_format = ["solc_json"]
```

**Note**: Normally, in Vyper, you cannot use `solc_json` with other formats.
However, `ape-vyper` handles this by running separately for the `solc_json` request.

Be sure to use the `--force` flag when compiling to ensure you get the solc JSON output.

```shell
ape compile file_needing_solc_json_format.vy -f
```

To get a dependency source file in this format, configure and compile the dependency.

```toml
[[tool.ape.dependencies]]
name = "my_dep"
config_override = { "vyper" = { "output_format" = ["solc_json"] } }
```

And then run:

```shell
ape pm compile --force
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ApeWorX/ape-vyper",
    "name": "ape-vyper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.10",
    "maintainer_email": null,
    "keywords": "ethereum",
    "author": "ApeWorX Ltd.",
    "author_email": "admin@apeworx.io",
    "download_url": "https://files.pythonhosted.org/packages/e1/c5/c449f91fa4dbe1e7a8990582dc3e03cf88703a590da019360b5bf0478ee1/ape_vyper-0.8.9.tar.gz",
    "platform": null,
    "description": "# Quick Start\n\nApe compiler plugin around [VVM](https://github.com/vyperlang/vvm)\n\n## Dependencies\n\n- [python3](https://www.python.org/downloads) version 3.10 up to 3.12.\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-vyper\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-vyper.git\ncd ape-vyper\npython3 setup.py install\n```\n\n## Quick Usage\n\nFirst, place Vyper contract source files (files with extension `.vy`) in your Ape project's contracts folder.\nAn example Vyper contract can be found [here](https://vyper.readthedocs.io/en/stable/vyper-by-example.html).\nThen, from your root Ape project folder, run the command:\n\n```bash\nape compile\n```\n\nThe `.vy` files in your project will compile into `ContractTypes` that you can deploy and interact with in Ape.\n\n### Contract Flattening\n\nFor ease of publishing, validation, and some other cases it's sometimes useful to \"flatten\" your contract into a single file.\nThis combines your contract and any imported interfaces together in a way the compiler can understand.\nYou can do so with a command like this:\n\n```bash\nape vyper flatten contracts/MyContract.vy build/MyContractFlattened.vy\n```\n\n> [!WARNING]\n> This feature is experimental. Please [report any bugs](https://github.com/ApeWorX/ape-solidity/issues/new?assignees=&labels=bug&projects=&template=bug.md) you find when trying it out.\n\n### Compiler Version\n\nBy default, the `ape-vyper` plugin uses version pragma for version specification.\nHowever, you can also configure the version directly in your `pyproject.toml` file:\n\n```toml\n[tool.vyper.version]\nversion = \"0.3.7\"\n```\n\n### EVM Versioning\n\nBy default, `ape-vyper` will use whatever version of EVM rules are set as default in the compiler version that gets used,\nor based on what the `#pragma evm-version ...` pragma comment specifies (available post-`v0.3.10`).\nSometimes, you might want to use a different version, such as deploying on Arbitrum or Optimism where new opcodes are not supported yet.\nIf you want to require a different version of EVM rules to use in the configuration of the compiler, set it in your `ape-config.yaml` like this:\n\n```toml\n[tool.ape.vyper]\nevm_version = \"paris\"\n```\n\n**NOTE**: The config value chosen will not override if a pragma is set in a contract.\n\n### Interfaces\n\nYou can not compile interface source files directly.\nThus, you must place interface files in a directory named `interfaces` in your `contracts_folder` e.g. `contracts/interfaces/IFace.vy`.\nThen, these files can be imported in other `.vy` sources files via:\n\n```python\nimport interfaces.IFace as IFace\n```\n\nAlternatively, use JSON interfaces from dependency contract types by listing them under the `import_remapping` key:\n\n```toml\n[[tool.ape.dependencies]]\nname = \"VyperVoting\"\ngithub = \"vyperlang/vyper\"\ncontracts_folder = \"examples/voting/\"\nversion = \"v0.3.8\"\n\n[tool.ape.vyper]\nimport_remapping = [\"voting=VyperVoting@v0.3.8\"]\n```\n\nImport the voting contract types like this:\n\n```python\n# @version 0.3.10\n\nimport voting.ballot as ballot\n```\n\n### Decimals\n\nTo use decimals on Vyper 0.4, use the following config:\n\n```toml\n[tool.ape.vyper]\nenable_decimals = true\n```\n\n### Pragmas\n\nApe-Vyper supports Vyper 0.3.10's [new pragma formats](https://github.com/vyperlang/vyper/pull/3493)\n\n#### Version Pragma\n\n```python\n#pragma version 0.3.10\n```\n\n#### EVM Version Pragma\n\n```python\n#pragma evm-version paris\n```\n\n#### Optimization Pragma\n\n```python\n#pragma optimize codesize\n```\n\n### VVM CLI\n\nYou can install versions of Vyper using the `ape vyper vvm` CLI tools.\nList installed versions using:\n\n```shell\nape vyper vvm list\n```\n\nTo list the available Vyper versions, do:\n\n```shell\nape vyper vvm list --available\n```\n\nInstall more versions using the command:\n\n```shell\nape vyper vvm install 0.3.7 0.3.10\n```\n\n### Custom Output Format\n\nTo customize Vyper's output format (like the native `-f` flag), you can configure the output format:\nFor example, to only get the ABI, do:\n\n```toml\n[tool.ape.vyper]\noutput_format = [\"abi\"]\n```\n\nTo do this using the CLI only (adhoc), use the following command:\n\n```shell\nape compile --config-override '{\"vyper\": {\"output_format\": [\"abi\"]}}'\n```\n\n#### Solc JSON Format\n\n`ape-vyper` supports the `socl_json` format.\nTo use this format, configure `ape-vyper` like:\n\n```toml\n[tool.ape.vyper]\noutput_format = [\"solc_json\"]\n```\n\n**Note**: Normally, in Vyper, you cannot use `solc_json` with other formats.\nHowever, `ape-vyper` handles this by running separately for the `solc_json` request.\n\nBe sure to use the `--force` flag when compiling to ensure you get the solc JSON output.\n\n```shell\nape compile file_needing_solc_json_format.vy -f\n```\n\nTo get a dependency source file in this format, configure and compile the dependency.\n\n```toml\n[[tool.ape.dependencies]]\nname = \"my_dep\"\nconfig_override = { \"vyper\" = { \"output_format\" = [\"solc_json\"] } }\n```\n\nAnd then run:\n\n```shell\nape pm compile --force\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Plugin for Ape Ethereum Framework for compiling Vyper contracts",
    "version": "0.8.9",
    "project_urls": {
        "Homepage": "https://github.com/ApeWorX/ape-vyper"
    },
    "split_keywords": [
        "ethereum"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cbf9f2d104fcb2c20c1aa5aa0936265c1c08ce81f6acf6a209ba187d19f01bfd",
                "md5": "7a8a6f1fb388133122ecef3722ae28dc",
                "sha256": "011b2a5959bdc73b98f0192a57b8b06c7288a48199ae48c59c172db4e379342f"
            },
            "downloads": -1,
            "filename": "ape_vyper-0.8.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7a8a6f1fb388133122ecef3722ae28dc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.10",
            "size": 47869,
            "upload_time": "2025-02-05T20:52:21",
            "upload_time_iso_8601": "2025-02-05T20:52:21.595777Z",
            "url": "https://files.pythonhosted.org/packages/cb/f9/f2d104fcb2c20c1aa5aa0936265c1c08ce81f6acf6a209ba187d19f01bfd/ape_vyper-0.8.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e1c5c449f91fa4dbe1e7a8990582dc3e03cf88703a590da019360b5bf0478ee1",
                "md5": "fc3ea746dd109651171df79b52f3112b",
                "sha256": "0e658fcf667ee3de3e64b645f5d7bcb8c986ff360076edcd947dbd1d5d41d47c"
            },
            "downloads": -1,
            "filename": "ape_vyper-0.8.9.tar.gz",
            "has_sig": false,
            "md5_digest": "fc3ea746dd109651171df79b52f3112b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.10",
            "size": 74671,
            "upload_time": "2025-02-05T20:52:23",
            "upload_time_iso_8601": "2025-02-05T20:52:23.102543Z",
            "url": "https://files.pythonhosted.org/packages/e1/c5/c449f91fa4dbe1e7a8990582dc3e03cf88703a590da019360b5bf0478ee1/ape_vyper-0.8.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-05 20:52:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ApeWorX",
    "github_project": "ape-vyper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ape-vyper"
}
        
Elapsed time: 0.89542s