Skip to content

Commit

Permalink
Merge pull request #209 from near/enable_pdm
Browse files Browse the repository at this point in the history
Add tooling to lint and format Python code
  • Loading branch information
aborg-dev authored Feb 6, 2024
2 parents 3d0d0a7 + b3165eb commit 41bb325
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ examples/.cache

# JS dependencies
node_modules/

# Python packages
.pdm-python
24 changes: 24 additions & 0 deletions docs/zkasm/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ In this guide, you'll learn how to use `cranelift` to compile `.wat` files into
git submodule update --init --recursive
```

3. **(optional) Setup Python tooling**:

If you plan to use Python tooling, you would need to install the dev dependencies.
First install PDM by following https://pdm-project.org/latest/#installation. Then install the
dependencies with:
```bash
pdm install
```

## Compilation Process

To compile a `.wat` file to `.zkasm`:
Expand Down Expand Up @@ -82,3 +91,18 @@ If you wish to compile a `.wat` file with logging (without generating a `.zkasm`
```bash
RUST_LOG=trace cargo run --features=all-arch -p cranelift-tools --bin=clif-util wasm --target=zkasm cranelift/zkasm_data/add.wat 2>trace.txt
```

## Python tooling

We use Python to orchestrate the execution of tests and benchmarks on zkAsm interpreter and
processing the execution results. The code lives in `ci/zkasm-result.py`.

We have tools to enforce consistent formatting and check for lint errors in Python files:

```bash
# Show lint errors.
pdm lint

# Format the code.
pdm fmt
```
76 changes: 76 additions & 0 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[project]
name = "wasmtime"
version = "0.1.0"
description = "Tools for testing zkAsm backend."
authors = [
{name = "Andrei Kashin", email = "andrei.kashin@near.org"},
{name = "Vikar Makouski", email = "viktar@near.org"}
]
dependencies = []
requires-python = ">=3.11"


[tool.pdm]
distribution = false

[tool.pdm.dev-dependencies]
lint = [
"ruff>=0.2.0",
"mypy>=1.8.0",
]

[tool.ruff]
include = ["ci/*.py"]

[tool.ruff.lint]
# Enable Pyflakes (`F`) and pycodestyle (`E`) by default.
select = ["F", "E"]

[tool.mypy]
files = ["ci/*.py"]

[tool.pdm.scripts]
lint = "ruff ."
fmt = "ruff format ."

0 comments on commit 41bb325

Please sign in to comment.