Skip to content

Commit

Permalink
switching to uv - final draft
Browse files Browse the repository at this point in the history
  • Loading branch information
adRn-s committed Oct 21, 2024
1 parent a2ecaa0 commit 1700bf2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 35 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
33 changes: 13 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions backend/requirements/dev.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
-r base.in

django-debug-toolbar
ipdb
# bpython ## can't use w/ playwright ATM. greenlet is in conflict...
Expand Down
1 change: 0 additions & 1 deletion backend/requirements/prod.in
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
-r base.in
2 changes: 0 additions & 2 deletions backend/requirements/testing.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
-r dev.in

pytest-cov
pytest-django
pytest-xdist
Expand Down

0 comments on commit 1700bf2

Please sign in to comment.