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

Use LLVM backend Python package #2849

Closed
wants to merge 22 commits into from
Closed
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
5 changes: 4 additions & 1 deletion .github/workflows/test-flake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ jobs:
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'

- name: 'Build K Framework'
run: GC_DONT_GC=1 nix build .
run: GC_DONT_GC=1 nix build .

- name: 'Build pyk'
run: GC_DONT_GC=1 nix build .#pyk
4 changes: 2 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/k-distribution/include/kframework/builtin/* @dwightguth @ehildenb
/Jenkinsfile @runtimeverification/admin
/.github/workflows/* @runtimeverification/admin
/Jenkinsfile @runtimeverification/admin @F-WRunTime
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's probably more appropriate to just add Freeman to the admin team than to explicitly hardcode his username here.

/.github/workflows/* @runtimeverification/admin @F-WRunTime
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
pyk = prev.poetry2nix.mkPoetryApplication {
python = prev.python39;
projectDir = ./pyk;
overrides = prev.poetry2nix.overrides.withDefaults
(finalPython: prevPython: { kllvm = prev.kllvm; });
};
})
];
Expand Down
2 changes: 2 additions & 0 deletions package/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export PREFIX

override_dh_auto_build:
mvn --batch-mode package -DskipTests -Dllvm.backend.prefix=$(PREFIX) -Dllvm.backend.destdir=$(DESTDIR)
package/fix-debian-kllvm-path
(cd pyk && rm poetry.lock && poetry update)

override_dh_auto_install:
package/package
Expand Down
2 changes: 2 additions & 0 deletions package/debian/rules.jammy
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export PREFIX

override_dh_auto_build:
mvn --batch-mode package -DskipTests -Dllvm.backend.prefix=$(PREFIX) -Dllvm.backend.destdir=$(DESTDIR)
package/fix-debian-kllvm-path
(cd pyk && rm poetry.lock && poetry update)

override_dh_auto_install:
package/package
Expand Down
10 changes: 10 additions & 0 deletions package/fix-debian-kllvm-path
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# This script is designed to be called _only_ during the K debian packaging
# process. It will make a destructive change to the Pyk project file to point to
# the debian root's installed path, rather than the default K build path.

ORIGINAL='kllvm = { path = "../k-distribution/target/release/k/lib/python" }'
NEW="kllvm = { path = \"$DESTDIR$PREFIX/lib/python\" }"

sed -i "s|$ORIGINAL|$NEW|g" pyk/pyproject.toml
11 changes: 10 additions & 1 deletion pyk/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
K_ROOT := $(abspath ..)
K_BIN := $(K_ROOT)/k-distribution/target/release/k/bin

ifeq ($(DESTDIR),)
K_LIB := $(K_ROOT)/k-distribution/target/release/k/lib
else
K_LIB := $(DESTDIR)$(PREFIX)/lib
endif

export PATH := $(K_BIN):$(PATH)


Expand All @@ -23,7 +29,10 @@ build:
poetry build

install: build
pip3 install ./dist/*.whl --root=$(DESTDIR) --prefix=$(PREFIX)
poetry export -f requirements.txt --without-hashes | \
pip3 install -r /dev/stdin --root=$(DESTDIR) --prefix=$(PREFIX)
pip3 install $(K_LIB)/python --root=$(DESTDIR) --prefix=$(PREFIX)
pip3 install ./dist/*.whl --no-dependencies --root=$(DESTDIR) --prefix=$(PREFIX)

poetry-install:
poetry install
Expand Down
84 changes: 49 additions & 35 deletions pyk/poetry.lock

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

3 changes: 2 additions & 1 deletion pyk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ flake8-comprehensions = "*"
isort = "*"
mypy = "*"
pep8-naming = "*"
kllvm = { path = "../k-distribution/target/release/k/lib/python" }

[tool.poetry.scripts]
pyk = "pyk.__main__:main"
Expand All @@ -37,5 +38,5 @@ line-length = 120
skip-string-normalization = true

[[tool.mypy.overrides]]
module = "graphviz"
module = ["graphviz", "kllvm"]
ignore_missing_imports = true
9 changes: 9 additions & 0 deletions pyk/src/tests/test_kllvm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from unittest import TestCase

import kllvm


class KLLVMTest(TestCase):
def test_basic(self):
sort_int = kllvm.ast.CompositeSort('SortInt')
self.assertEqual(str(sort_int), "SortInt{}")