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 1 commit
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
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)
50 changes: 50 additions & 0 deletions src/algokit/cli/compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import logging

import click

from algokit.core.proc import run
from algokit.core.utils import find_valid_pipx_command

logger = logging.getLogger(__name__)


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


@compile_group.command(
"py",
short_help="Compile Python to TEAL with Puyapy",
PatrickDinh marked this conversation as resolved.
Show resolved Hide resolved
context_settings={
"ignore_unknown_options": True,
},
)
@click.option(
"-v",
"--version",
"version",
required=False,
default=None,
help=("Puyapy compiler version. " "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) with Puyapy
"""

pipx_command = find_valid_pipx_command(
"Unable to find pipx install so that `Puyapy` compiler can be installed; "
"please install pipx via https://pypa.github.io/pipx/ "
"and then try `algokit compile py ...` again."
)
run(
[
*pipx_command,
"run",
"puya" if version is None else f"puya=={version}",
*puya_args,
],
bad_return_code_error_message=("Puyapy failed to compile the contract(s)"),
)
Loading