Move dependencies to pyproject.toml

Update CI workflows, docker files, etc.
This commit is contained in:
Roland Geider
2025-04-27 17:22:35 +02:00
parent f1862bdb14
commit a814bae43b
14 changed files with 1894 additions and 186 deletions

View File

@@ -10,7 +10,7 @@ updates:
schedule:
interval: "daily"
- package-ecosystem: "pip"
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "daily"

View File

@@ -5,68 +5,61 @@ on:
branches: [ master, ]
paths:
- '**.py'
- 'requirements.txt'
- 'pyproject.toml'
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, ]
paths:
- '**.py'
- 'requirements.txt'
- 'pyproject.toml'
jobs:
ci-job:
runs-on: ubuntu-latest
strategy:
matrix:
#TODO: pypy3 has problems compiling lxml
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
name: CI job (python ${{ matrix.python-version }})
steps:
- uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
cache: 'pip'
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Display Python version
run: python -c "import sys; print(sys.version)"
run: python --version
- name: Install dependencies
run: |
pip install --upgrade pip
pip install wheel coverage
pip install -r requirements_dev.txt
pip install -r requirements_prod.txt
pip install -e .
uv sync --group dev
# Only run the tests with coverage for one version of python
- name: Test the application with coverage
if: matrix.python-version == 3.11
if: matrix.python-version == 3.13
run: |
source .venv/bin/activate
wger create-settings
coverage run --source='.' ./manage.py test
coverage lcov
- name: Test the application
if: matrix.python-version != 3.11
if: matrix.python-version != 3.13
run: |
source .venv/bin/activate
wger create-settings
python manage.py test
- name: Coveralls
if: matrix.python-version == 3.11
uses: coverallsapp/github-action@master
if: matrix.python-version == 3.13
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.lcov

View File

@@ -1,31 +0,0 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Upload Package to PyPI
on:
release:
types: [created]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*

View File

@@ -16,15 +16,19 @@ LABEL maintainer="Roland Geider <roland@geider.net>"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update \
&& apt install --no-install-recommends -y \
ca-certificates \
python3 \
adduser \
locales \
python3-pip \
sqlite3 \
wget \
tzdata \
libpq5 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen en_US.UTF-8
&& locale-gen en_US.UTF-8 \
&& wget https://bootstrap.pypa.io/get-pip.py \
&& python3 get-pip.py --no-warn-script-location --break-system-packages
# Environmental variables
ENV LANG=en_US.UTF-8

View File

@@ -1,17 +1,17 @@
#
# A wger installation under apache with WSGI
# A demo wger installation under apache with WSGI
#
# Note: you MUST build this image from the project's root!
# docker build -f extras/docker/demo/Dockerfile --tag wger/demo .
#
# Please consult the documentation for usage
# docker run -ti --name wger.demo --publish 8000:80 wger/demo
# docker run --rm --name wger.demo --publish 8000:80 wger/demo
#
# To stop the container:
# sudo docker container stop wger.demo
# docker container stop wger.demo
#
# To start again
# sudo docker container start --attach wger.demo
# docker container start --attach wger.demo
#
##########
@@ -33,26 +33,29 @@ RUN apt update \
rustc \
cargo \
yarnpkg \
sassc
sassc \
&& ln -s /usr/bin/yarnpkg /usr/bin/yarn \
&& ln -s /usr/bin/sassc /usr/bin/sass
# Build the necessary python wheels
# Note that the --mount is a workaround for https://github.com/rust-lang/cargo/issues/8719
COPY requirements* ./
RUN --mount=type=tmpfs,target=/root/.cargo pip3 wheel --no-cache-dir --wheel-dir /wheels -r requirements_docker.txt \
COPY pyproject.toml .
COPY wger/version.py ./wger/version.py
COPY wger/__init__.py ./wger/__init__.py
COPY README.md ./README.md
RUN --mount=type=tmpfs,target=/root/.cargo pip3 wheel --no-cache-dir --wheel-dir /wheels --group docker . \
&& pip3 install --break-system-packages --user --no-cache-dir /wheels/*
COPY . /home/wger/src
WORKDIR /home/wger/src
RUN ln -s /usr/bin/yarnpkg /usr/bin/yarn \
&& ln -s /usr/bin/sassc /usr/bin/sass \
&& yarn install \
RUN yarn install \
&& yarn build:css:sass
########
# Final
########
FROM wger/base:latest
FROM wger/base:latest AS final
LABEL maintainer="Roland Geider <roland@geider.net>"
ENV TERM=xterm
ARG DOCKER_DIR=./extras/docker/demo
@@ -60,12 +63,15 @@ EXPOSE 80
# Install dependencies
RUN apt-get install --no-install-recommends -y \
apache2 \
cron \
python3-venv \
libapache2-mod-wsgi-py3 \
python3-wheel
RUN apt update \
&& apt install --no-install-recommends -y \
apache2 \
cron \
python3-venv \
libapache2-mod-wsgi-py3 \
python3-wheel \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Configure apache
COPY ${DOCKER_DIR}/wger.conf /etc/apache2/sites-available/
@@ -115,7 +121,6 @@ RUN . /home/wger/venv/bin/activate \
&& python3 manage.py collectstatic --no-input
USER root
RUN chown :www-data -R /home/wger/db \
&& chown www-data:www-data -R /home/wger/static \

View File

@@ -10,18 +10,20 @@ USER root
WORKDIR /home/wger/src
RUN apt-get update && \
apt-get install -y \
apt-get install --no-install-recommends -y \
git \
vim \
yarnpkg \
sassc
COPY ../../../requirements.txt /tmp/requirements.txt
COPY ../../../requirements_dev.txt /tmp/requirements_dev.txt
RUN ln -s /usr/bin/yarnpkg /usr/bin/yarn \
sassc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& ln -s /usr/bin/yarnpkg /usr/bin/yarn \
&& ln -s /usr/bin/sassc /usr/bin/sass
COPY ./pyproject.toml /tmp/pyproject.toml
COPY ./wger/version.py /tmp/wger/version.py
COPY ./wger/__init__.py /tmp/wger/__init__.py
COPY ./README.md /tmp/README.md
USER wger
RUN pip3 install --break-system-packages --user -r /tmp/requirements.txt \
&& pip3 install --break-system-packages --user -r /tmp/requirements_dev.txt
RUN pip3 install --break-system-packages --user --group dev /tmp/

View File

@@ -30,25 +30,43 @@ RUN apt update \
cargo
# Build the necessary python wheels
# Note that the --mount tmpfs is a workaround for https://github.com/rust-lang/cargo/issues/8719
COPY requirements* ./
#
# PS: the --mount tmpfs is a workaround for https://github.com/rust-lang/cargo/issues/8719
#
# PPS: actually only pyproject.toml is needed here, but it seems there is no way
# to tell pip to only build the dependencies and not the project itself as well,
# so we copy enough to make this is possible
COPY pyproject.toml .
COPY wger/version.py ./wger/version.py
COPY wger/__init__.py ./wger/__init__.py
COPY README.md ./README.md
RUN --mount=type=tmpfs,target=/root/.cargo \
pip3 wheel --no-cache-dir --wheel-dir /wheels -r requirements_docker.txt \
&& pip3 install --break-system-packages --user --no-cache-dir /wheels/*
pip3 wheel \
--no-cache-dir \
--wheel-dir /wheels \
--group docker . \
&& pip3 install \
--break-system-packages \
--no-warn-script-location \
--root-user-action ignore \
--user \
--no-cache-dir /wheels/* \
&& ln -s /usr/bin/yarnpkg /usr/bin/yarn \
&& ln -s /usr/bin/sassc /usr/bin/sass
# Download and copy js and css files
COPY . /home/wger/src
WORKDIR /home/wger/src
RUN ln -s /usr/bin/yarnpkg /usr/bin/yarn \
&& ln -s /usr/bin/sassc /usr/bin/sass \
&& yarn install \
RUN yarn install \
&& yarn build:css:sass
########
# Final
########
FROM wger/base:latest
FROM wger/base:latest AS final
LABEL maintainer="Roland Geider <roland@geider.net>"
ARG DOCKER_DIR=./extras/docker/production
ENV PATH="/home/wger/.local/bin:$PATH"
@@ -57,9 +75,10 @@ EXPOSE 8000
# Set up the application
COPY --from=builder --chown=wger:wger /root/.local /home/wger/.local
WORKDIR /home/wger/src
COPY --chown=wger:wger . /home/wger/src
COPY --from=builder --chown=wger:wger /root/.local /home/wger/.local
COPY --from=builder --chown=wger:wger /home/wger/src/wger/core/static/yarn /home/wger/src/wger/core/static/yarn
COPY ${DOCKER_DIR}/settings.py /home/wger/src
COPY ${DOCKER_DIR}/settings.py /tmp/

View File

@@ -4,9 +4,10 @@ build-backend = "hatchling.build"
[project]
name = "wger"
dynamic = ["version", "dependencies"]
dynamic = ["version", ]
authors = [
{ name = "Roland Geider", email = "roland@geider.net" },
{ name = "wger team", email = "hello@wger.de" },
]
description = "FLOSS workout, fitness and weight manager/tracker"
readme = "README.md"
@@ -26,6 +27,62 @@ classifiers = [
'Programming Language :: Python :: 3.13',
]
dependencies = [
"bleach[css]~=6.2",
"celery[redis]==5.4.0",
"crispy-bootstrap5==2024.10",
"django==5.2",
"django-activity-stream==2.0.0",
"django-axes[ipware]==7.0.2",
"django-bootstrap-breadcrumbs2==1.0.0",
"django-compressor~=4.5",
"django-cors-headers==4.7.0",
"django-crispy-forms~=2.3",
"django-email-verification~=0.3.3",
"django-environ==0.12.0",
"django-filter==25.1",
"django-formtools~=2.5",
"django-prometheus==2.3.1",
"django-recaptcha~=4.0.0",
"django-redis==5.4.0",
"django-simple-history~=3.8",
"django-sortedm2m~=4.0.0",
"django-storages~=1.14",
"djangorestframework==3.15.2",
"djangorestframework-simplejwt[crypto]==5.5.0",
"drf-spectacular[sidecar]==0.28.0",
"easy-thumbnails==2.10",
"flower==2.0.1",
"fontawesomefree~=6.6.0",
"icalendar==6.1.2",
"invoke==2.2.0",
"openfoodfacts==2.5.0",
"packaging==25.0",
"pillow==11.1.0",
"psycopg[binary]==3.2.6",
"reportlab==4.3.1",
"requests==2.32.3",
"tqdm==4.67.1",
"tzdata==2025.2",
]
[dependency-groups]
dev = [
"coverage==7.8.0",
"django-debug-toolbar==5.1.0",
"django-extensions~=3.2",
"faker==37.1.0",
"isort==6.0.1",
"ruff==0.11.2",
"tblib==3.0.0",
"wheel==0.45.1",
]
docker = [
"gunicorn==23.0.0",
]
[project.urls]
Homepage = "https://wger.de/"
Documentation = "https://wger.readthedocs.io"
@@ -34,6 +91,7 @@ Issues = "https://github.com/wger-project/wger/issues"
Changelog = "https://wger.readthedocs.io/en/latest/changelog.html"
Funding = "https://buymeacoffee.com/wger"
[project.scripts]
wger = "wger.__main__:main"
@@ -41,9 +99,6 @@ wger = "wger.__main__:main"
include-package-data = false
packages = ["wger"]
[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }
[tool.distutils.bdist_wheel]
universal = 1
@@ -158,3 +213,4 @@ force_adds = false
# Include a trailing comma after the imports. This ensures that yapf doesn't
# reformat the code
include_trailing_comma = true

View File

@@ -1,47 +0,0 @@
#
# Common requirements for wger
#
# Application
Django==4.2.20
bleach[css]~=6.2
celery[redis]==5.4.0
crispy-bootstrap5==2024.10
django-activity-stream==2.0.0
django-axes[ipware]==7.0.2
django-bootstrap-breadcrumbs2==1.0.0 # fork of django-bootstrap-breadcrumbs, we might need to migrate away completely
django-crispy-forms~=2.3
django-email-verification~=0.3.3
django-environ==0.12.0
django-formtools~=2.5
django-prometheus==2.3.1
django-recaptcha~=4.0.0
django-simple-history~=3.8
django-storages~=1.14
django-compressor~=4.5
drf-spectacular[sidecar]==0.28.0
easy-thumbnails==2.10
flower==2.0.1
fontawesomefree~=6.6.0
icalendar==6.1.2
invoke==2.2.0
openfoodfacts==2.5.0
pillow==11.1.0
packaging==24.2
reportlab==4.3.1
requests==2.32.3
tqdm==4.67.1
tzdata==2025.2
# AWS
#boto3
# REST API
django-cors-headers==4.7.0
django-filter==25.1
djangorestframework==3.15.2
djangorestframework-simplejwt[crypto]==5.5.0
# Not used anymore, but needed because some modules are imported in DB migration
# files
django-sortedm2m~=3.1

View File

@@ -1,23 +0,0 @@
#
# Requirements for wger during development only
#
# Regular packages
-r requirements.txt
# Building/installing
wheel==0.45.1
# for ingredient import script from OFF
pymongo==4.11.3
# for running the dummy entry generators
faker==37.1.0
# Development packages
django-extensions~=3.2
coverage==7.8.0
django-debug-toolbar==5.1.0
isort==6.0.1
ruff==0.11.2
tblib==3.0.0

View File

@@ -1,10 +0,0 @@
#
# Requirements for wger for production (docker setup)
#
# Regular packages
-r requirements.txt
django-redis==5.4.0
gunicorn==23.0.0
psycopg==3.2.6

View File

@@ -1,9 +0,0 @@
#
# Requirements for wger for production
#
# Regular packages
-r requirements.txt
psycopg[binary]==3.2.6
django-redis==5.4.0

1749
uv.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -44,5 +44,5 @@ class RoutineGeneratorTestCase(WgerTestCase):
# Assert
# Things like nr of training days or exercises are random
self.assertGreaterEqual(WorkoutLog.objects.filter(routine__user_id=1).count(), 130)
self.assertGreaterEqual(WorkoutLog.objects.filter(routine__user_id=1).count(), 100)
self.assertLessEqual(WorkoutLog.objects.filter(routine__user_id=1).count(), 800)