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
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
Prev Previous commit
Next Next commit
chore: support "compile python" and "compile py"
  • Loading branch information
PatrickDinh committed Mar 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6043f6f1668d8e0ea4e078fe7b9d5393615448aa
19 changes: 16 additions & 3 deletions src/algokit/cli/compile.py
Original file line number Diff line number Diff line change
@@ -2,13 +2,26 @@

import click

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

logger = logging.getLogger(__name__)


@click.group("compile", hidden=True)
class CompileGroup(click.Group):
def get_command(self, ctx: click.Context, cmd_name: str) -> click.Command | None:
rv = click.Group.get_command(self, ctx, cmd_name)
if rv is not None:
return rv

command_dict = {"py": "python"}
if cmd_name in command_dict:
return click.Group.get_command(self, ctx, command_dict[cmd_name])

return None


@click.group("compile", cls=CompileGroup, hidden=True)
@click.option(
"-v",
"--version",
@@ -31,7 +44,7 @@ def compile_group(context: click.Context, version: str | None) -> None:


@compile_group.command(
"py",
"python",
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={
File renamed without changes.
12 changes: 6 additions & 6 deletions tests/compile/test_py.py → tests/compile/test_python.py
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ def test_compile_py_help(mocker: MockerFixture) -> None:
proc_mock.set_output(["poetry", "run", "puyapy", "-h"], output=["Puyapy help"])

mocker.patch("algokit.core.proc.Popen").side_effect = proc_mock.popen
result = invoke("compile py -h")
result = invoke("compile python -h")

assert result.exit_code == 0
verify(result.output)
@@ -53,7 +53,7 @@ def test_puyapy_is_not_installed_anywhere(dummy_contract_path: Path, mocker: Moc

mocker.patch("algokit.core.proc.Popen").side_effect = proc_mock.popen

result = invoke(f"compile py {_normalize_path(dummy_contract_path)}")
result = invoke(f"compile python {_normalize_path(dummy_contract_path)}")

assert result.exit_code == 0
verify(result.output)
@@ -85,7 +85,7 @@ def test_puyapy_is_installed_in_project(dummy_contract_path: Path, mocker: Mocke

mocker.patch("algokit.core.proc.Popen").side_effect = proc_mock.popen

result = invoke(f"compile py {_normalize_path(dummy_contract_path)}")
result = invoke(f"compile python {_normalize_path(dummy_contract_path)}")

assert result.exit_code == 0
verify(result.output)
@@ -100,7 +100,7 @@ def test_puyapy_is_installed_globally(dummy_contract_path: Path, mocker: MockerF

mocker.patch("algokit.core.proc.Popen").side_effect = proc_mock.popen

result = invoke(f"compile py {_normalize_path(dummy_contract_path)}")
result = invoke(f"compile python {_normalize_path(dummy_contract_path)}")

assert result.exit_code == 0
verify(result.output)
@@ -114,7 +114,7 @@ def test_valid_contract(cwd: Path, output_path: Path) -> None:
contract_path = cwd / "contract.py"
contract_path.write_text(VALID_PUYA_CONTRACT_FILE_CONTENT)

result = invoke(f"compile py {_normalize_path(contract_path)} --out-dir {_normalize_path(output_path)}")
result = invoke(f"compile python {_normalize_path(contract_path)} --out-dir {_normalize_path(output_path)}")

# Only check for the exit code, don't check the results from PuyaPy
assert result.exit_code == 0
@@ -127,7 +127,7 @@ def test_invalid_contract(cwd: Path, output_path: Path) -> None:

contract_path = cwd / "contract.py"
contract_path.write_text(INVALID_PUYA_CONTRACT_FILE_CONTENT)
result = invoke(f"compile py {_normalize_path(contract_path)} --out-dir {_normalize_path(output_path)}")
result = invoke(f"compile python {_normalize_path(contract_path)} --out-dir {_normalize_path(output_path)}")

# Only check for the exit code and the error message from AlgoKit CLI
assert result.exit_code == 1