Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 37 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[flake8]
ignore =
E203,
E241,
W291,
E302,
E501,
W503,
E741,

per-file-ignores =
pyteal/compiler/optimizer/__init__.py: F401
examples/application/asset.py: F403, F405
examples/application/security_token.py: F403, F405
examples/application/vote.py: F403, F405
examples/signature/atomic_swap.py: F403, F405
examples/signature/basic.py: F403, F405
examples/signature/dutch_auction.py: F403, F405
examples/signature/periodic_payment_deploy.py: F403, F405
examples/signature/recurring_swap.py: F403, F405
examples/signature/split.py: F403, F405
examples/signature/periodic_payment.py: F403, F405
examples/signature/recurring_swap_deploy.py: F403, F405
pyteal/__init__.py: F401, F403
pyteal/ir/ops.py: E221
tests/module_test.py: F401, F403
# Temporary ignores while merging
pyteal/ast/abi/array_base_test.py: F403, F405
pyteal/ast/abi/array_dynamic_test.py: F403, F405
pyteal/ast/abi/array_static_test.py: F403, F405
pyteal/ast/abi/bool_test.py: F403, F405
pyteal/ast/abi/method_return_test.py: F403, F405
pyteal/ast/abi/tuple_test.py: F403, F405
pyteal/ast/abi/type_test.py: F403, F405
pyteal/ast/abi/uint_test.py: F403, F405
pyteal/ast/abi/util_test.py: F403, F405
# End temporary ignores while merging
34 changes: 12 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ on:
- v**
branches:
- master

jobs:
build-test:
runs-on: ubuntu-20.04
container: python:${{ matrix.python }}-slim
container: python:${{ matrix.python }}
strategy:
matrix:
python: ['3.10']
Expand All @@ -19,16 +20,11 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install pip dependencies
run: |
pip install -r requirements.txt
pip install -e .
- name: Install python dependencies
run: make setup-development
- name: Build and Test
run: |
python scripts/generate_init.py --check
black --check .
mypy pyteal
pytest
run: make build-and-test

build-docset:
runs-on: ubuntu-20.04
container: python:3.10 # Needs `make`, can't be slim
Expand All @@ -37,22 +33,16 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install pip dependencies
run: |
pip install -r requirements.txt
pip install -r docs/requirements.txt
pip install doc2dash
- name: Install python dependencies
run: make setup-docs
- name: Make docs
run: |
cd docs
make html
doc2dash --name pyteal --index-page index.html --online-redirect-url https://pyteal.readthedocs.io/en/ _build/html
tar -czvf pyteal.docset.tar.gz pyteal.docset
run: make bundle-docs
- name: Archive docset
uses: actions/upload-artifact@v2
with:
name: pyteal.docset
path: docs/pyteal.docset.tar.gz

upload-to-pypi:
runs-on: ubuntu-20.04
container: python:3.10
Expand All @@ -64,9 +54,9 @@ jobs:
with:
fetch-depth: 0
- name: Install dependencies
run: pip install wheel
run: make setup-wheel
- name: Build package
run: python setup.py sdist bdist_wheel
run: make bdist-wheel
- name: Release
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -54,8 +52,8 @@ coverage.xml
.pytest_cache/

# Tests generating TEAL output to compared against an expected example.
tests/teal/*.teal
!tests/teal/*_expected.teal
tests/**/*.teal
!tests/**/*_expected.teal

# Translations
*.mo
Expand All @@ -76,6 +74,7 @@ instance/

# Sphinx documentation
docs/_build/
pyteal.docset*

# PyBuilder
target/
Expand Down Expand Up @@ -133,3 +132,6 @@ dmypy.json
# IDE
.idea
.vscode

# mac OS
.DS_Store
29 changes: 29 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
tools:
python: "3.10"
# You can also specify other tool versions:
# nodejs: "16"
# rust: "1.55"
# golang: "1.17"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF
# formats:
# - pdf

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt
23 changes: 0 additions & 23 deletions .readthedocs.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.11.1

## Fixed
* Fix readthedocs build issue introduced in v0.11.0 ([#276](https://github.com/algorand/pyteal/pull/276), [#279](https://github.com/algorand/pyteal/pull/279)).

# 0.11.0

## Added
Expand Down
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
setup-development:
pip install -e.[development]

setup-docs: setup-development
pip install -r docs/requirements.txt
pip install doc2dash

setup-wheel:
pip install wheel

bdist-wheel:
python setup.py sdist bdist_wheel

bundle-docs-clean:
rm -rf docs/pyteal.docset

bundle-docs: bundle-docs-clean
cd docs && \
make html && \
doc2dash --name pyteal --index-page index.html --online-redirect-url https://pyteal.readthedocs.io/en/ _build/html && \
tar -czvf pyteal.docset.tar.gz pyteal.docset

generate-init:
python -m scripts.generate_init

check-generate-init:
python -m scripts.generate_init --check

ALLPY = docs examples pyteal scripts tests *.py
black:
black --check $(ALLPY)

flake8:
flake8 $(ALLPY)

MYPY = pyteal scripts
mypy:
mypy $(MYPY)

lint: black flake8 mypy

test-unit:
pytest

build-and-test: check-generate-init lint test-unit

# Extras:
coverage:
pytest --cov-report html --cov=pyteal
47 changes: 29 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
![PyTeal logo](https://github.com/algorand/pyteal/blob/master/docs/pyteal.png?raw=true)
<!-- markdownlint-disable-file MD041 -->

![PyTeal logo](https://github.com/algorand/pyteal/blob/master/docs/pyteal.png?raw=true)

# PyTeal: Algorand Smart Contracts in Python

Expand All @@ -8,59 +9,69 @@
[![Documentation Status](https://readthedocs.org/projects/pyteal/badge/?version=latest)](https://pyteal.readthedocs.io/en/latest/?badge=latest)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

PyTeal is a Python language binding for [Algorand Smart Contracts (ASC1s)](https://developer.algorand.org/docs/features/asc1/).
PyTeal is a Python language binding for [Algorand Smart Contracts (ASC1s)](https://developer.algorand.org/docs/features/asc1/).

Algorand Smart Contracts are implemented using a new language that is stack-based,
called [Transaction Execution Approval Language (TEAL)](https://developer.algorand.org/docs/features/asc1/teal/).
Algorand Smart Contracts are implemented using a new language that is stack-based,
called [Transaction Execution Approval Language (TEAL)](https://developer.algorand.org/docs/features/asc1/teal/).

However, TEAL is essentially an assembly language. With PyTeal, developers can express smart contract logic purely using Python.
However, TEAL is essentially an assembly language. With PyTeal, developers can express smart contract logic purely using Python.
PyTeal provides high level, functional programming style abstractions over TEAL and does type checking at construction time.

### Install
## Install

PyTeal requires Python version >= 3.10.

To manage multiple Python versions use tooling like [pyenv](https://github.com/pyenv/pyenv).

#### Recommended: Install from PyPi
### Recommended: Install from PyPi

Install the latest official release from PyPi:

* `pip install pyteal`

#### Install Latest Commit
### Install Latest Commit

If needed, it's possible to install directly from the latest commit on master to use unreleased features:

> **WARNING:** Unreleased code is experimental and may not be backwards compatible or function properly. Use extreme caution when installing PyTeal this way.

* `pip install git+https://github.com/algorand/pyteal`

### Documentation
## Documentation

* [PyTeal Docs](https://pyteal.readthedocs.io/)
* `docs/` ([README](docs/README.md)) contains raw docs.

### Development Setup
## Development Setup

Setup venv (one time):
* `python3 -m venv venv`

* `python3 -m venv venv`

Active venv:
* `. venv/bin/activate` (if your shell is bash/zsh)
* `. venv/bin/activate.fish` (if your shell is fish)

Pip install PyTeal in editable state
* `pip install -e .`
* `. venv/bin/activate` (if your shell is bash/zsh)
* `. venv/bin/activate.fish` (if your shell is fish)

Pip install PyTeal in editable state with dependencies:

* `make setup-development`
* OR if you don't have `make` installed:
* `pip install -e.[development]`
* Note, that if you're using `zsh` you'll need to escape the brackets: `pip install -e.\[development\]`

Install dependencies:
* `pip install -r requirements.txt`

Type checking using mypy:

* `mypy pyteal`

Run tests:

* `pytest`

Format code:

* `black .`

Lint using flake8:

* `flake8 docs examples pyteal scripts tests *.py`
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# -- Project information -----------------------------------------------------

project = "PyTeal"
copyright = "2021, Algorand"
copyright = "2022, Algorand"
author = "Algorand"


Expand Down
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sphinx_rtd_theme
sphinx==4.2.0
sphinx-rtd-theme==1.0.0
py-algorand-sdk
1 change: 0 additions & 1 deletion examples/application/vote_deploy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# based off https://github.com/algorand/docs/blob/cdf11d48a4b1168752e6ccaf77c8b9e8e599713a/examples/smart_contracts/v2/python/stateful_smart_contracts.py

import base64
import datetime

from algosdk.future import transaction
from algosdk import account, mnemonic
Expand Down
10 changes: 7 additions & 3 deletions examples/signature/periodic_payment_deploy.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env python3

from pyteal import *
import uuid, params, base64
import base64
import params
import uuid

from algosdk import algod, transaction, account, mnemonic
from periodic_payment import periodic_payment, tmpl_amt
from periodic_payment import periodic_payment

from pyteal import *

# --------- compile & send transaction using Goal and Python SDK ----------

Expand Down
Loading