From 1700bf22b5fae4fefff84c8f82b7c7cf93248a50 Mon Sep 17 00:00:00 2001 From: adRn-s Date: Mon, 21 Oct 2024 14:58:42 +0200 Subject: [PATCH] switching to uv - final draft --- .github/workflows/deps.yml | 25 +++++++++++++++---------- Makefile | 33 +++++++++++++-------------------- backend/requirements/dev.in | 2 -- backend/requirements/prod.in | 1 - backend/requirements/testing.in | 2 -- 5 files changed, 28 insertions(+), 35 deletions(-) diff --git a/.github/workflows/deps.yml b/.github/workflows/deps.yml index b129ea63c..27e60f4a4 100644 --- a/.github/workflows/deps.yml +++ b/.github/workflows/deps.yml @@ -21,20 +21,25 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: - cache: "pip" - cache-dependency-path: backend/requirements/${{ matrix.python-version }}/testing.txt python-version: ${{ matrix.python-version }} - + + - name: Set up UV for py ${{ matrix.python-version }} + uses: yezz123/setup-uv@v4 + - name: Backend Update run: | - mkdir -p backend/requirements/${{ matrix.python-version }} - ls backend/requirements/*.in | cut -d'/' -f3 | rev | cut -d. -f2 | rev | xargs -I{} ln -sf ../{}.in backend/requirements/${{ matrix.python-version }}/{}.in - python -m pip install --upgrade pip - pip install pip-tools pip-compile-multi - pip-compile-multi -d backend/requirements/${{ matrix.python-version }} --backtracking --autoresolve --allow-unsafe + export this=backend/requirements/${{ matrix.python-version }} + uv pip compile --no-progress --no-cache --universal --python-version ${{ matrix.python-version }} \ + backend/requirements/base.in -o ${this}/base.txt + uv pip compile --no-progress --no-cache --universal --python-version ${{ matrix.python-version }} \ + backend/requirements/prod.in -c ${this}/base.txt -o ${this}/prod.txt + uv pip compile --no-progress --no-cache --universal --python-version ${{ matrix.python-version }} \ + backend/requirements/dev.in -c ${this}/base.txt -o ${this}/dev.txt + uv pip compile --no-progress --no-cache --universal --python-version ${{ matrix.python-version }} \ + backend/requirements/testing.in -c ${this}/dev.txt -o ${this}/testing.txt - name: Test installation - run: pip install -r backend/requirements/${{ matrix.python-version }}/testing.txt + run: uv pip install --system -r backend/requirements/${{ matrix.python-version }}/testing.txt - name: Create PR uses: peter-evans/create-pull-request@v6 @@ -48,7 +53,7 @@ jobs: commit-message: | Update python dependencies. - Run of `pip-compile-multi` to update all python dependencies. + Run of `uv pip compile` to update all python dependencies. vuejs: if: github.repository == 'maxplanck-ie/parkour2' diff --git a/Makefile b/Makefile index 9195b4b90..66c8e772d 100644 --- a/Makefile +++ b/Makefile @@ -284,24 +284,25 @@ precomitupd: @pre-commit autoupdate compile: - # @test -d ./env_dev || \ - # { echo "ERROR: venv not found! Try: make env-setup-dev"; exit 1; } - # @if [[ :$PATH: == *:"env_dev":* ]] ; then - # source ./env_dev/bin/activate && echo "venv activated!" - # uv pip install --system --upgrade pip wheel setuptools pip-compile-multi - # else - # exit 1 - # fi - @awk '/python-version:/ { \ + @PY_VERSIONS=$$(awk '/python-version:/ { \ match($$0, /\[(.*)\]/, a); \ split(a[1], versions, ","); \ for (i in versions) { \ gsub(/^[ '\'']+|[ '\'']+$$/, "", versions[i]); \ print versions[i]; \ } \ - }' .github/workflows/django.yml | \ - xargs -I{} pip-compile-multi --allow-unsafe --backtracking --autoresolve \ - -d backend/requirements/{}/ + }' .github/workflows/django.yml); \ + for version in $$PY_VERSIONS; do \ + this=backend/requirements/$$version; \ + uv pip compile --no-progress --no-cache --universal --python-version $$version \ + backend/requirements/base.in -o $$this/base.txt; \ + uv pip compile --no-progress --no-cache --universal --python-version $$version \ + backend/requirements/prod.in -c $$this/base.txt -o $$this/prod.txt; \ + uv pip compile --no-progress --no-cache --universal --python-version $$version \ + backend/requirements/dev.in -c $$this/base.txt -o $$this/dev.txt; \ + uv pip compile --no-progress --no-cache --universal --python-version $$version \ + backend/requirements/testing.in -c $$this/dev.txt -o $$this/testing.txt; \ + done ncu: # @npm install -g npm-check-updates @@ -316,14 +317,6 @@ env-setup-dev: @echo "$ echo ruff black djlint | xargs -n1 uv tool install --python 3.12" @echo "$ uv tool install --python 3.12 pre-commit --with pre-commit-uv" -env-setup-dev-old: - # @env python3 -m venv env_dev && \ - # source ./env_dev/bin/activate && \ - # env python3 -m pip install --upgrade pip && \ - # pip install djlint pre-commit uv \ - # aider-chat[help] --extra-index-url https://download.pytorch.org/whl/cpu - # @deactivate - open-pr: @git pull && git push && git pull origin develop @gh pr create --title "quick upgrade" --fill -B develop diff --git a/backend/requirements/dev.in b/backend/requirements/dev.in index 977a23dad..29e45e053 100644 --- a/backend/requirements/dev.in +++ b/backend/requirements/dev.in @@ -1,5 +1,3 @@ --r base.in - django-debug-toolbar ipdb # bpython ## can't use w/ playwright ATM. greenlet is in conflict... diff --git a/backend/requirements/prod.in b/backend/requirements/prod.in index 25a6ceb08..e69de29bb 100644 --- a/backend/requirements/prod.in +++ b/backend/requirements/prod.in @@ -1 +0,0 @@ --r base.in diff --git a/backend/requirements/testing.in b/backend/requirements/testing.in index c3c514c6c..d7113f88e 100644 --- a/backend/requirements/testing.in +++ b/backend/requirements/testing.in @@ -1,5 +1,3 @@ --r dev.in - pytest-cov pytest-django pytest-xdist