Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add compile py command #441

Merged
merged 40 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d8813d1
feat: add compile py command
PatrickDinh Feb 28, 2024
2b94a38
chore: fix PuyaPy casing
PatrickDinh Feb 28, 2024
cd966fa
chore: draft docs
PatrickDinh Feb 28, 2024
ddf4d5f
chore: generate docs
PatrickDinh Feb 28, 2024
a6ca216
chore: test and document
PatrickDinh Feb 28, 2024
7120d1e
chore: docs
PatrickDinh Feb 28, 2024
3ce4a79
chore: improve detect puyapy version
PatrickDinh Feb 29, 2024
e6a7780
chore: docs
PatrickDinh Feb 29, 2024
c14ed79
chore: fix test
PatrickDinh Feb 29, 2024
5af9e0b
chore: clean up
PatrickDinh Feb 29, 2024
1641ff1
chore: bug and docs
PatrickDinh Feb 29, 2024
b1fb1b8
chore: code comment
PatrickDinh Feb 29, 2024
01f0015
chore: first test
PatrickDinh Feb 29, 2024
61ac65b
chore: fix tests
PatrickDinh Feb 29, 2024
c60fa7d
chore: fix tests
PatrickDinh Feb 29, 2024
24470b6
chore: fix tests
PatrickDinh Feb 29, 2024
71c3bd0
chore: tests
PatrickDinh Feb 29, 2024
6d8dde4
chore: test
PatrickDinh Feb 29, 2024
e183619
chore: turns out I don't need this
PatrickDinh Feb 29, 2024
50d9ef2
chore: move --version flag to the group
PatrickDinh Mar 1, 2024
b4f5d59
chore: fix the tests
PatrickDinh Mar 1, 2024
a5c40df
Merge remote-tracking branch 'origin/main' into integrate-puya
PatrickDinh Mar 3, 2024
ace7e4a
chore: disable compile_group command
PatrickDinh Mar 3, 2024
fab3315
chore: add the compile group back, hidden from users
PatrickDinh Mar 4, 2024
2f4ad48
chore: delete doc
PatrickDinh Mar 4, 2024
3f043d9
chore: pr feedback
PatrickDinh Mar 4, 2024
78a1b87
chore: install puya during CI
PatrickDinh Mar 4, 2024
b350faa
Don't check for PuyaPy outputs
PatrickDinh Mar 4, 2024
550465d
chore: only run puyapy tests for python 3.12
PatrickDinh Mar 5, 2024
2e1e02b
chore: oops
PatrickDinh Mar 5, 2024
6386367
chore: run tests with --no-color flag
PatrickDinh Mar 5, 2024
1da08b1
chore: fix tests
PatrickDinh Mar 5, 2024
3d9ed2b
chore: only skip the e2e tests
PatrickDinh Mar 5, 2024
28085ec
chore: address PR feedback
PatrickDinh Mar 6, 2024
f067ede
Merge remote-tracking branch 'origin/main' into integrate-puya
PatrickDinh Mar 6, 2024
6043f6f
chore: support "compile python" and "compile py"
PatrickDinh Mar 11, 2024
0960710
Merge remote-tracking branch 'origin/main' into integrate-puya
PatrickDinh Mar 11, 2024
636384e
chore: show all sub commands
PatrickDinh Mar 11, 2024
5ae5fc4
chore: PR feedback
PatrickDinh Mar 11, 2024
51a79ab
chore: clean up
PatrickDinh Mar 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 74 additions & 40 deletions docs/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,64 +18,70 @@
- [--interactive, --non-interactive, --ci](#--interactive---non-interactive---ci-1)
- [npm](#npm)
- [poetry](#poetry)
- [compile](#compile)
- [py](#py)
- [Options](#options-4)
- [-v, --version ](#-v---version-)
- [Arguments](#arguments)
- [PUYA_ARGS](#puya_args)
- [completions](#completions)
- [install](#install)
- [Options](#options-4)
- [Options](#options-5)
- [--shell ](#--shell-)
- [uninstall](#uninstall)
- [Options](#options-5)
- [Options](#options-6)
- [--shell ](#--shell--1)
- [config](#config)
- [version-prompt](#version-prompt)
- [Arguments](#arguments)
- [Arguments](#arguments-1)
- [ENABLE](#enable)
- [deploy](#deploy)
- [Options](#options-6)
- [Options](#options-7)
- [-C, --command ](#-c---command-)
- [--interactive, --non-interactive, --ci](#--interactive---non-interactive---ci-2)
- [-P, --path ](#-p---path-)
- [--deployer ](#--deployer-)
- [--dispenser ](#--dispenser-)
- [Arguments](#arguments-1)
- [Arguments](#arguments-2)
- [ENVIRONMENT_NAME](#environment_name)
- [dispenser](#dispenser)
- [fund](#fund)
- [Options](#options-7)
- [Options](#options-8)
- [-r, --receiver ](#-r---receiver-)
- [-a, --amount ](#-a---amount-)
- [--whole-units](#--whole-units)
- [limit](#limit)
- [Options](#options-8)
- [Options](#options-9)
- [--whole-units](#--whole-units-1)
- [login](#login)
- [Options](#options-9)
- [Options](#options-10)
- [--ci](#--ci)
- [-o, --output ](#-o---output-)
- [-f, --file ](#-f---file-)
- [logout](#logout)
- [refund](#refund)
- [Options](#options-10)
- [Options](#options-11)
- [-t, --txID ](#-t---txid-)
- [doctor](#doctor)
- [Options](#options-11)
- [Options](#options-12)
- [-c, --copy-to-clipboard](#-c---copy-to-clipboard)
- [explore](#explore)
- [Arguments](#arguments-2)
- [Arguments](#arguments-3)
- [NETWORK](#network)
- [generate](#generate)
- [client](#client)
- [Options](#options-12)
- [Options](#options-13)
- [-o, --output ](#-o---output--1)
- [-l, --language ](#-l---language-)
- [Arguments](#arguments-3)
- [Arguments](#arguments-4)
- [APP_SPEC_PATH_OR_DIR](#app_spec_path_or_dir)
- [goal](#goal)
- [Options](#options-13)
- [Options](#options-14)
- [--console](#--console)
- [Arguments](#arguments-4)
- [Arguments](#arguments-5)
- [GOAL_ARGS](#goal_args)
- [init](#init)
- [Options](#options-14)
- [Options](#options-15)
- [-n, --name ](#-n---name-)
- [-t, --template ](#-t---template-)
- [--template-url ](#--template-url-)
Expand All @@ -91,33 +97,33 @@
- [console](#console)
- [explore](#explore-1)
- [logs](#logs)
- [Options](#options-15)
- [Options](#options-16)
- [--follow, -f](#--follow--f)
- [--tail ](#--tail-)
- [reset](#reset)
- [Options](#options-16)
- [Options](#options-17)
- [--update, --no-update](#--update---no-update)
- [start](#start)
- [Options](#options-17)
- [Options](#options-18)
- [-n, --name ](#-n---name--1)
- [status](#status)
- [stop](#stop)
- [task](#task)
- [analyze](#analyze)
- [Options](#options-18)
- [Options](#options-19)
- [-r, --recursive](#-r---recursive)
- [--force](#--force-1)
- [--diff](#--diff)
- [-o, --output ](#-o---output--2)
- [-e, --exclude ](#-e---exclude-)
- [Arguments](#arguments-5)
- [Arguments](#arguments-6)
- [INPUT_PATHS](#input_paths)
- [ipfs](#ipfs)
- [Options](#options-19)
- [Options](#options-20)
- [-f, --file ](#-f---file--1)
- [-n, --name ](#-n---name--2)
- [mint](#mint)
- [Options](#options-20)
- [Options](#options-21)
- [--creator ](#--creator-)
- [-n, --name ](#-n---name--3)
- [-u, --unit ](#-u---unit-)
Expand All @@ -129,66 +135,66 @@
- [--nft, --ft](#--nft---ft)
- [-n, --network ](#-n---network-)
- [nfd-lookup](#nfd-lookup)
- [Options](#options-21)
- [Options](#options-22)
- [-o, --output ](#-o---output--3)
- [Arguments](#arguments-6)
- [Arguments](#arguments-7)
- [VALUE](#value)
- [opt-in](#opt-in)
- [Options](#options-22)
- [Options](#options-23)
- [-a, --account ](#-a---account-)
- [-n, --network ](#-n---network--1)
- [Arguments](#arguments-7)
- [Arguments](#arguments-8)
- [ASSET_IDS](#asset_ids)
- [opt-out](#opt-out)
- [Options](#options-23)
- [Options](#options-24)
- [-a, --account ](#-a---account--1)
- [--all](#--all)
- [-n, --network ](#-n---network--2)
- [Arguments](#arguments-8)
- [Arguments](#arguments-9)
- [ASSET_IDS](#asset_ids-1)
- [send](#send)
- [Options](#options-24)
- [Options](#options-25)
- [-f, --file ](#-f---file--2)
- [-t, --transaction ](#-t---transaction-)
- [-n, --network ](#-n---network--3)
- [sign](#sign)
- [Options](#options-25)
- [Options](#options-26)
- [-a, --account ](#-a---account--2)
- [-f, --file ](#-f---file--3)
- [-t, --transaction ](#-t---transaction--1)
- [-o, --output ](#-o---output--4)
- [--force](#--force-2)
- [transfer](#transfer)
- [Options](#options-26)
- [Options](#options-27)
- [-s, --sender ](#-s---sender-)
- [-r, --receiver ](#-r---receiver--1)
- [--asset, --id ](#--asset---id-)
- [-a, --amount ](#-a---amount--1)
- [--whole-units](#--whole-units-2)
- [-n, --network ](#-n---network--4)
- [vanity-address](#vanity-address)
- [Options](#options-27)
- [Options](#options-28)
- [-m, --match ](#-m---match-)
- [-o, --output ](#-o---output--5)
- [-a, --alias ](#-a---alias-)
- [--file-path ](#--file-path-)
- [-f, --force](#-f---force)
- [Arguments](#arguments-9)
- [Arguments](#arguments-10)
- [KEYWORD](#keyword)
- [wallet](#wallet)
- [Options](#options-28)
- [Options](#options-29)
- [-a, --address ](#-a---address-)
- [-m, --mnemonic](#-m---mnemonic)
- [-f, --force](#-f---force-1)
- [Arguments](#arguments-10)
- [ALIAS_NAME](#alias_name)
- [Arguments](#arguments-11)
- [ALIAS_NAME](#alias_name)
- [Arguments](#arguments-12)
- [ALIAS](#alias)
- [Options](#options-29)
- [Options](#options-30)
- [-f, --force](#-f---force-2)
- [Arguments](#arguments-12)
- [Arguments](#arguments-13)
- [ALIAS](#alias-1)
- [Options](#options-30)
- [Options](#options-31)
- [-f, --force](#-f---force-3)

# algokit
Expand Down Expand Up @@ -278,6 +284,34 @@ Installs Python Poetry (if not present) and runs poetry install in the current w
algokit bootstrap poetry [OPTIONS]
```

## compile

Compile high level language smart contracts to TEAL

```shell
algokit compile [OPTIONS] COMMAND [ARGS]...
```

### py

Compile Python to TEAL with PuyaPy, review [https://github.com/algorandfoundation/puya](https://github.com/algorandfoundation/puya) for usage

```shell
algokit compile py [OPTIONS] [PUYA_ARGS]...
```

### Options


### -v, --version <version>
PuyaPy compiler version, for example, 0.6.0. Default to latest

### Arguments


### PUYA_ARGS
Optional argument(s)

## completions

Install and Uninstall AlgoKit shell integrations.
Expand Down
21 changes: 21 additions & 0 deletions docs/features/compile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# AlgoKit Compile

The AlgoKit Compile feature allows you to compile your smart contracts to TEAL.

## Functionality

The AlgoKit Compile feature allows you to compile your smart contracts to TEAL.

Supported languages are:

- Python is compiled to TEAL with [PuyaPy](https://github.com/algorandfoundation/puya). When using this feature, all PuyaPy options are supported.

# Examples

For example, to compile a Python smart contract and output to a directory, run

```
algokit compile py hello_world/contract.py --out-dir hello_world/out
```

Any compilation errors will be logged to the command line output.
2 changes: 2 additions & 0 deletions src/algokit/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import click

from algokit.cli.bootstrap import bootstrap_group
from algokit.cli.compile import compile_group
from algokit.cli.completions import completions_group
from algokit.cli.config import config_group
from algokit.cli.deploy import deploy_command
Expand Down Expand Up @@ -49,3 +50,4 @@ def algokit(*, skip_version_check: bool) -> None:
algokit.add_command(deploy_command)
algokit.add_command(dispenser_group)
algokit.add_command(task_group)
algokit.add_command(compile_group)
46 changes: 46 additions & 0 deletions src/algokit/cli/compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import logging

import click

from algokit.core.compile import find_valid_puyapy_command
from algokit.core.proc import run

logger = logging.getLogger(__name__)


@click.group("compile")
def compile_group() -> None:
"""Compile high level language smart contracts to TEAL"""


@compile_group.command(
"py",
short_help="Compile Python to TEAL with PuyaPy",
help="Compile Python to TEAL with PuyaPy, review https://github.com/algorandfoundation/puya for usage",
context_settings={
"ignore_unknown_options": True,
},
)
@click.option(
"-v",
"--version",
"version",
required=False,
default=None,
help=("PuyaPy compiler version, for example, 0.6.0. Default to latest"),
)
@click.argument("puya_args", nargs=-1, type=click.UNPROCESSED)
def compile_py_command(version: str | None, puya_args: list[str]) -> None:
"""
Compile Python contract(s) to TEAL with PuyaPy
"""

puya_command = find_valid_puyapy_command(version)

run(
[
*puya_command,
*puya_args,
],
bad_return_code_error_message=("PuyaPy failed to compile the contract(s)"),
)
Loading