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

misc: Add makefile and update readme #1173

Merged
merged 10 commits into from
Jun 22, 2023
48 changes: 48 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables


.PHONY: clean filecheck pytest tests rerun-notebooks precommit-install precommit black pyright

# remove all caches and the venv
clean:
rm -rf venv .pytest_cache *.egg-info .coverage.*
AntonLydike marked this conversation as resolved.
Show resolved Hide resolved

# run filecheck tests
filecheck:
lit -vv tests/filecheck
AntonLydike marked this conversation as resolved.
Show resolved Hide resolved

# run pytest tests
pytest:
AntonLydike marked this conversation as resolved.
Show resolved Hide resolved
pytest tests -W error -vv

# run all tests
tests: pytest filecheck
echo test

# re-generate the output from all jupyter notebooks in the docs directory
rerun-notebooks:
jupyter nbconvert --ClearMetadataPreprocessor.enabled=True --inplace --to notebook --execute docs/*.ipynb

# set up all precommit hooks
precommit-install:
pre-commit install

# run all precommit hooks and apply them
precommit:
pre-commit run --all

# run pyright on all files in the current git commit
pyright:
pyright $(shell git diff --staged --name-only)

# run black on all files currently staged
black:
black $(shell git diff --staged --name-only)
AntonLydike marked this conversation as resolved.
Show resolved Hide resolved

# set up the venv with all dependencies for development
venv: requirements-optional.txt requirements.txt
python3 -m venv venv
source venv/bin/activate
pip install -r requirements-optional.txt requirements.txt
pip install -e ".[extras]"
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ for users interested in that use case.
- [A DSL for defining new IRs](https://xdsl.dev/xdsl/retro/notebooks/?path=irdl.ipynb)
- [Connecting xDSL with MLIR](docs/mlir_interoperation.md)

We provide a Makefile containing a lot of common tasks, which might provide
an overview of common actions.

## xDSL Developer Setup

To contribute to the development of xDSL follow the subsequent steps.
Expand All @@ -67,7 +70,8 @@ To contribute to the development of xDSL follow the subsequent steps.
```bash
git clone https://github.com/xdslproject/xdsl.git
cd xdsl
pip install --editable ".[extras]"
# set up the venv and install everything
make venv
```

### Testing
Expand All @@ -81,9 +85,12 @@ pytest

# Executes filecheck tests
lit tests/filecheck

# run all tests using makefile
make tests
```

### Formatting
### Formatting and Typechecking

All python code used in xDSL uses [black](https://github.com/psf/black) to
format the code in a uniform manner.
Expand All @@ -92,17 +99,18 @@ To automate the formatting, we use pre-commit hooks from the
[pre-commit](https://pypi.org/project/pre-commit/) package.

```bash
# Install pre-commit version in the optional requirement files
pip install --requirement requirements-optional.txt

# Install the pre-commit on your `.git` folder
# Be sure to run this in your virtual environment
pre-commit install

# Optionally test the hook by running it on all files
pre-commit run --all-files
make precommit-install
# to run the hooks:
make precommit
# alternatively, running black on all staged files:
make black # or simply black $(git diff --staged --name-only)
```

Furthermore, all python code must run through [pyright](https://github.com/microsoft/pyright)
without errors. Pyright can be run on all staged files through the
makefile using `make pyright`.

### Discussion

You can also join the discussion at our [Zulip chat room](https://xdsl.zulipchat.com), kindly supported by community hosting from [Zulip](https://zulip.com/).