Skip to content

Commit 0534d02

Browse files
bbyalcinkayarv-auditorjuliankuners
authored
Migrate from poetry to uv (#733)
* cruft update + resolve conflicts in pyproject.toml manually * remove poetry.lock, create uv.lock * Makefile: poetry to uv * update `Dockerfile` * Update `test-pr.yml` * Set Version: 0.1.133 * Fix `Dockerfile` * move `pykwasm/nix` to `nix`, delete `pykwasm/flake.nix` * `flake.nix`: poetry to uv * refactor and fix nix derivation * remove old nix patches * adapt `uv.lock` to match nix & CU uv version * update `uv2nix` and `pyproject-build-systems` in CI * `update-version.yml`: fix kframework update command * `Makefile`: use `uv --project <PROJECT>` option * fix kframework update command: `==` => `>=` --------- Co-authored-by: devops <[email protected]> Co-authored-by: Julian Kuners <[email protected]>
1 parent 18f6588 commit 0534d02

27 files changed

+1800
-2044
lines changed

.github/actions/with-docker/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ runs:
1616
1717
TAG=runtimeverificationinc/${CONTAINER_NAME}
1818
K_COMMIT=$(cat ./deps/k_release)
19+
UV_VERSION=$(cat deps/uv_release)
1920
20-
docker build . --tag ${TAG} --build-arg K_COMMIT=${K_COMMIT}
21+
docker build . \
22+
--tag ${TAG} \
23+
--build-arg K_COMMIT=${K_COMMIT} \
24+
--build-arg UV_VERSION=$(UV_VERSION)
2125
2226
docker run \
2327
--name ${CONTAINER_NAME} \

.github/workflows/test-pr.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ jobs:
4141
uses: actions/checkout@v3
4242
with:
4343
submodules: recursive
44-
- name: 'Install Poetry'
45-
uses: Gr1N/setup-poetry@v8
46-
- name: 'Build pykwasm'
47-
run: poetry -C pykwasm install
44+
- name: 'Get uv release'
45+
id: uv_release
46+
run: |
47+
echo uv_version=$(cat deps/uv_release) >> "${GITHUB_OUTPUT}"
48+
- name: 'Install uv'
49+
uses: astral-sh/setup-uv@v6
50+
with:
51+
version: ${{ steps.uv_release.outputs.uv_version }}
4852
- name: 'Run code quality checks'
4953
run: make -C pykwasm check
5054
- name: 'Run pyupgrade'
@@ -66,10 +70,8 @@ jobs:
6670
uses: ./.github/actions/with-docker
6771
with:
6872
container-name: kwasm-ci-conformance-${{ github.sha }}
69-
- name: 'Build pykwasm'
70-
run: docker exec -u user kwasm-ci-conformance-${GITHUB_SHA} poetry -C pykwasm install
71-
- name: 'Build LLVM definition'
72-
run: docker exec -u user kwasm-ci-conformance-${GITHUB_SHA} poetry -C pykwasm run kdist -v build wasm-semantics.llvm
73+
- name: 'Build KWasm definitions'
74+
run: docker exec -u user kwasm-ci-conformance-${GITHUB_SHA} make build
7375
- name: 'Run integration tests'
7476
run: docker exec -u user kwasm-ci-conformance-${GITHUB_SHA} make -C pykwasm cov-integration
7577
- name: 'Run simple tests'
@@ -97,10 +99,8 @@ jobs:
9799
uses: ./.github/actions/with-docker
98100
with:
99101
container-name: kwasm-ci-prove-${{ github.sha }}
100-
- name: 'Build pykwasm'
101-
run: docker exec -u user kwasm-ci-prove-${GITHUB_SHA} poetry -C pykwasm install
102-
- name: 'Build Haskell definitions'
103-
run: docker exec -u user kwasm-ci-prove-${GITHUB_SHA} poetry -C pykwasm run kdist -v build wasm-semantics.{kwasm-lemmas,wrc20} -j2
102+
- name: 'Build KWasm definitions'
103+
run: docker exec -u user kwasm-ci-prove-${GITHUB_SHA} make build
104104
- name: 'Run prover tests'
105105
run: docker exec -u user kwasm-ci-prove-${GITHUB_SHA} make -j6 test-prove
106106
- name: 'Tear down Docker'

.github/workflows/update-version.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
branches:
55
- '_update-deps/runtimeverification/k'
66
- '_update-deps/runtimeverification/rv-nix-tools'
7+
- '_update-deps-cron/uv2nix'
8+
- '_update-deps-cron/pyproject-build-systems'
79

810
# Stop in progress workflows on the same branch and same workflow to use latest committed code
911
concurrency:
@@ -24,8 +26,6 @@ jobs:
2426
- run: |
2527
git config user.name devops
2628
git config user.email [email protected]
27-
- name: 'Install Poetry'
28-
uses: Gr1N/setup-poetry@v8
2929
- name: 'Install Nix'
3030
uses: cachix/install-nix-action@v22
3131
with:
@@ -39,17 +39,35 @@ jobs:
3939
with:
4040
name: k-framework
4141
authToken: '${{ secrets.CACHIX_PUBLIC_TOKEN }}'
42-
- name: 'Update pyk release tag'
42+
# note: we install the same version of `uv` as used by `uv2nix` in order to match the nix derivation
43+
- name: 'Update uv release tag'
44+
id: uv_release
45+
run: |
46+
UV2NIX_VERSION=$(cat deps/uv2nix)
47+
UV_VERSION=$(curl -s https://raw.githubusercontent.com/pyproject-nix/uv2nix/$(cat deps/uv2nix)/pkgs/uv-bin/srcs.json | jq -r .version)
48+
[[ "$UV_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
49+
echo $UV_VERSION > deps/uv_release
50+
git add deps/uv_release && git commit -m "Sync uv version: uv ${UV_VERSION}" || true
51+
echo uv_version=$UV_VERSION >> "${GITHUB_OUTPUT}"
52+
- name: 'Install uv'
53+
uses: astral-sh/setup-uv@v6
54+
with:
55+
version: ${{ steps.uv_release.outputs.uv_version }}
56+
- name: 'Update uv files'
4357
run: |
4458
K_VERSION=$(cat deps/k_release)
45-
sed -i 's!kframework = "^[v0-9\.]*"!kframework = "'^${K_VERSION}'"!' pykwasm/pyproject.toml
46-
poetry -C pykwasm update
47-
git add pykwasm/ && git commit -m "pykwasm/: sync poetry files ${K_VERSION}" || true
59+
sed -i 's! "kframework>=[0-9\.]*",! "kframework>='${K_VERSION}'",!' pykwasm/pyproject.toml
60+
uv lock --upgrade
61+
git add pykwasm/ && git commit -m "pykwasm/: sync uv files ${K_VERSION}" || true
4862
- name: 'Update Nix flake inputs'
4963
run: |
5064
K_VERSION=v"$(cat deps/k_release)"
65+
UV2NIX_VERSION=$(cat deps/uv2nix)
66+
PYPROJECT_BUILD_SYSTEMS_VERSION=$(cat deps/pyproject-build-systems)
5167
RV_NIX_TOOLS_VERSION=$(cat deps/rv-nix-tools)
5268
sed -i 's! k-framework.url = "github:runtimeverification/k/v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+"! k-framework.url = "github:runtimeverification/k/'"${K_VERSION}"'"!' flake.nix
69+
sed -i 's! uv2nix.url = "github:pyproject-nix/uv2nix/[a-z0-9\.]*"! uv2nix.url = "github:pyproject-nix/uv2nix/'"${UV2NIX_VERSION}"'"!' flake.nix
70+
sed -i 's! pyproject-build-systems.url = "github:pyproject-nix/build-system-pkgs/[a-z0-9\.]*"! pyproject-build-systems.url = "github:pyproject-nix/build-system-pkgs/'"${PYPROJECT_BUILD_SYSTEMS_VERSION}"'"!' flake.nix
5371
sed -i 's! rv-nix-tools.url = "github:runtimeverification/rv-nix-tools/[a-z0-9\.]*"! rv-nix-tools.url = "github:runtimeverification/rv-nix-tools/'"${RV_NIX_TOOLS_VERSION}"'"!' flake.nix
5472
nix flake update
5573
git add flake.nix flake.lock && git commit -m 'flake.{nix,lock}: update Nix derivations' || true

Dockerfile

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
1-
ARG Z3_VERSION
2-
ARG K_COMMIT
3-
4-
ARG Z3_VERSION=4.12.1
5-
FROM runtimeverificationinc/z3:ubuntu-jammy-${Z3_VERSION} as Z3
6-
71
ARG K_COMMIT
82
FROM runtimeverificationinc/kframework-k:ubuntu-jammy-${K_COMMIT}
93

10-
COPY --from=Z3 /usr/bin/z3 /usr/bin/z3
11-
124
RUN apt-get update \
135
&& apt-get upgrade --yes \
146
&& apt-get install --yes \
15-
cmake \
16-
curl \
17-
pandoc \
18-
python3 \
19-
python3-pip \
20-
wabt
7+
curl wabt
218

229
ARG USER_ID=1000
2310
ARG GROUP_ID=1000
@@ -26,12 +13,8 @@ RUN groupadd -g $GROUP_ID user && useradd -m -u $USER_ID -s /bin/sh -g user user
2613
USER user:user
2714
WORKDIR /home/user
2815

29-
RUN curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.3 python3 -
30-
31-
RUN pip3 install --user \
32-
cytoolz \
33-
numpy
34-
35-
ENV PATH=/home/user/.local/bin:$PATH
16+
ENV PATH=/home/user/.local/bin:${PATH}
3617

37-
RUN poetry --version
18+
ARG UV_VERSION
19+
RUN curl -LsSf https://astral.sh/uv/$UV_VERSION/install.sh | sh \
20+
&& uv --version

Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
UV := uv
2+
UV_RUN := $(UV) run --
3+
4+
15
.PHONY: all \
26
test test-execution test-simple test-prove \
37
test-conformance test-conformance-parse test-conformance-supported \
@@ -11,28 +15,24 @@ all: build
1115
# -------------------
1216

1317
ifneq ($(NIX),1)
14-
POETRY := poetry -C pykwasm
15-
POETRY_RUN := $(POETRY) run --
16-
KDIST := $(POETRY_RUN) kdist
18+
UV := uv --project pykwasm
19+
UV_RUN := $(UV) run --
20+
KDIST := $(UV_RUN) kdist
1721
endif
1822

19-
.PHONY: pykwasm
20-
pykwasm:
21-
$(POETRY) install
22-
2323
.PHONY: build
24-
build: pykwasm
25-
$(KDIST) -v build -j3
24+
build:
25+
$(KDIST) -v build -j3 wasm-semantics.*
2626

2727
.PHONY: clean
28-
clean: pykwasm
28+
clean:
2929
$(KDIST) clean
3030

3131

3232
# Testing
3333
# -------
3434

35-
TEST := $(POETRY_RUN) kwasm
35+
TEST := $(UV_RUN) kwasm
3636
CHECK := git --no-pager diff --no-index --ignore-all-space -R
3737

3838
TEST_CONCRETE_BACKEND := llvm

deps/pyk_release

Lines changed: 0 additions & 1 deletion
This file was deleted.

deps/pyproject-build-systems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7dba6dbc73120e15b558754c26024f6c93015dd7

deps/uv2nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
680e2f8e637bc79b84268949d2f2b2f5e5f1d81c

deps/uv_release

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.7.2

flake.lock

Lines changed: 91 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)