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

Pyk scripts #10

Merged
merged 13 commits into from
Aug 23, 2024
Merged
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ syntax-test: $(SYNTAX_OUTPUTS)
indexing-test: $(INDEXING_OUTPUTS)

$(RUST_TIMESTAMP): $(SEMANTICS_FILES)
$$(which kompile) rust-semantics/rust.md -o $(RUST_KOMPILED)
$$(which kompile) rust-semantics/rust.md --emit-json -o $(RUST_KOMPILED)

$(SYNTAX_OUTPUT_DIR)/%.rs-parsed: $(SYNTAX_INPUT_DIR)/%.rs $(RUST_TIMESTAMP)
mkdir -p $(SYNTAX_OUTPUT_DIR)
Expand Down
18 changes: 18 additions & 0 deletions rust-lite/.cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"template": "https://github.com/runtimeverification/python-project-template",
"commit": "601d5e2a0e8a98c87dcb1ae694d22d76d0114e01",
"checkout": null,
"context": {
"cookiecutter": {
"project_name": "rust-lite",
"project_slug": "rust-lite",
"package_name": "rust_lite",
"version": "0.1.0",
"description": "Pyk scripts for running our Rust Lite Semantics",
"author_name": "Runtime Verification, Inc.",
"author_email": "[email protected]",
"_template": "https://github.com/runtimeverification/python-project-template"
}
},
"directory": null
}
7 changes: 7 additions & 0 deletions rust-lite/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
max-line-length = 120
extend-select = B9, TC1
extend-ignore = B950,E,W1,W2,W3,W4,W5
per-file-ignores =
*/__init__.py: F401
type-checking-strict = true
3 changes: 3 additions & 0 deletions rust-lite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist/
__pycache__/
.coverage
74 changes: 74 additions & 0 deletions rust-lite/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
POETRY := poetry
POETRY_RUN := $(POETRY) run


default: check test-unit

all: check cov

.PHONY: clean
clean:
rm -rf dist .coverage cov-* .mypy_cache .pytest_cache
find -type d -name __pycache__ -prune -exec rm -rf {} \;

.PHONY: build
build:
$(POETRY) build

.PHONY: poetry-install
poetry-install:
$(POETRY) install


# Tests

TEST_ARGS :=

test: test-all

test-all: poetry-install
$(POETRY_RUN) pytest src/tests --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS)

test-unit: poetry-install
$(POETRY_RUN) pytest src/tests/unit --maxfail=1 --verbose $(TEST_ARGS)

test-integration: poetry-install
$(POETRY_RUN) pytest src/tests/integration --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS)


# Checks and formatting

format: autoflake isort black
check: check-flake8 check-mypy check-autoflake check-isort check-black

check-flake8: poetry-install
$(POETRY_RUN) flake8 src

check-mypy: poetry-install
$(POETRY_RUN) mypy src

autoflake: poetry-install
$(POETRY_RUN) autoflake --quiet --in-place src

check-autoflake: poetry-install
$(POETRY_RUN) autoflake --quiet --check src

isort: poetry-install
$(POETRY_RUN) isort src

check-isort: poetry-install
$(POETRY_RUN) isort --check src

black: poetry-install
$(POETRY_RUN) black src

check-black: poetry-install
$(POETRY_RUN) black --check src


# Optional tools

SRC_FILES := $(shell find src -type f -name '*.py')

pyupgrade: poetry-install
$(POETRY_RUN) pyupgrade --py310-plus $(SRC_FILES)
23 changes: 23 additions & 0 deletions rust-lite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# rust-lite


## Installation

Prerequsites: `python >= 3.10`, `pip >= 20.0.2`, `poetry >= 1.3.2`.

```bash
make build
pip install dist/*.whl
```


## For Developers

Use `make` to run common tasks (see the [Makefile](Makefile) for a complete list of available targets).

* `make build`: Build wheel
* `make check`: Check code style
* `make format`: Format code
* `make test-unit`: Run unit tests

For interactive use, spawn a shell with `poetry shell` (after `poetry install`), then run an interpreter.
41 changes: 41 additions & 0 deletions rust-lite/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
description = "rust-lite - Pyk scripts for running our Rust Lite Semantics";
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils";
poetry2nix.url = "github:nix-community/poetry2nix";
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
let
allOverlays = [
poetry2nix.overlay
(final: prev: {
rust-lite = prev.poetry2nix.mkPoetryApplication {
python = prev.python310;
projectDir = ./.;
groups = [];
# We remove `dev` from `checkGroups`, so that poetry2nix does not try to resolve dev dependencies.
checkGroups = [];
};
})
];
in flake-utils.lib.eachSystem [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
] (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = allOverlays;
};
in {
packages = rec {
inherit (pkgs) rust-lite;
default = rust-lite;
};
}) // {
overlay = nixpkgs.lib.composeManyExtensions allOverlays;
};
}
Loading
Loading