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

refactor: remplacer poetry par uv #875

Merged
merged 10 commits into from
Jan 13, 2025
Merged
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
25 changes: 13 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,30 @@ jobs:
--health-retries 5

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: 💾 Create a database to check migrations
run: |
psql <<SQL
CREATE DATABASE communaute;
SQL
- name: 💂 Install Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: pip
cache-dependency-path: requirements/dev.txt
- name: 📥 Install dependencies
- name: 💂 Install uv
uses: astral-sh/setup-uv@v5
- name: 💂 Set up Python
run: uv python install
- name: 💂 Install the project
run: uv sync --dev
# export venv path to $GITHUB_ENV to make it avail at each step
- name: Activate virtualenv
run: |
vincentporte marked this conversation as resolved.
Show resolved Hide resolved
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
- name: ✨ Black, ruff & djlint
source .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: ✨ Ruff & djlint
run: make quality
- name: 🚧 create cache table
run: python manage.py createcachetable
- name: 🚧 collect static for testing purposes
run: |
python manage.py collectstatic
python manage.py collectstatic --no-input
python manage.py compress
- name: 🚧 compile translations
run: |
Expand Down
13 changes: 0 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
repos:
- repo: https://github.com/python-poetry/poetry
rev: '1.8.0'
hooks:
- id: poetry-check
- id: poetry-export
args: ["-f", "requirements.txt", "-o", "requirements/dev.txt", "--with", "dev",]
- id: poetry-export
args: ["-f", "requirements.txt", "-o", "requirements/base.txt"]
- repo: local
hooks:
- id: black
name: Black
entry: black
types: [python]
language: system
- id: ruff-format
name: Ruff format
entry: ruff format
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ DJLINT_EXCLUDE ?= lacommunaute/templates/middleware/

.PHONY: quality fix
quality:
black --check lacommunaute
ruff check lacommunaute
djlint --lint --check lacommunaute --exclude $(DJLINT_EXCLUDE)

fix:
black lacommunaute
ruff check --fix lacommunaute
djlint --reformat lacommunaute

Expand Down
29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Installer l'environnement virtuel et les dépendances :

```bash
$ poetry install
$ uv sync
```

Copier le fichier `.env.template` en `.env` et le modifier en fonction de vos besoins.
Expand All @@ -17,7 +17,7 @@ $ cp .env.template .env
Accéder à l'environnement virtuel :

```bash
$ poetry shell
$ source .venv/bin/activate
```

## Démarrer les instances
Expand Down Expand Up @@ -66,25 +66,25 @@ $ docker exec -it commu_django bash
Ajouter d'une dépendance :

```bash
$ poetry add django-anymail
$ uv add django-anymail
```

Ajouter d'une dépendance de développement :

```bash
$ poetry add --group dev poethepoet
$ uv add --dev beautifulsoup4
```

Mettre à jour des dépendances :
Mettre à jour les dépendances :

```bash
$ poetry update;poetry lock
$ uv lock
```

Générer les fichiers `requirements`
Mettre à jour son environnement virtuel :

```bash
$ poetry run poe export;poetry run poe export_dev
$ uv sync
```

## Développement
Expand Down Expand Up @@ -138,25 +138,20 @@ Créer et lier les addons

Créer les variables d'environnement suivantes dans le configuration provider

- ALLOWED_HOSTS
- CC_PIP_REQUIREMENTS_FILE
- CC_PRE_BUILD_HOOK
- CC_PRE_RUN_HOOK
- CC_PYTHON_BACKEND
- CC_PYTHON_MANAGE_TASKS
- CC_PYTHON_MODULE
- CC_PYTHON_VERSION
- CC_UWSGI_DISABLE_FILE_WRAPPER
- DJANGO_DEBUG
- DJANGO_SECRET_KEY
- DJANGO_SETTINGS_MODULE
- OPENID_CONNECT_BASE_URL
- OPENID_CONNECT_CLIENT_ID
- OPENID_CONNECT_CLIENT_SECRET
- OPENID_CONNECT_REALM
- PORT
- PYTHONPATH
- SENTRY_DSN
- SIB_API_KEY
- STATIC_FILES_PATH
- STATIC_URL_PREFIX
- UV_PROJECT_ENVIRONMENT

### pour le déploiment des recettes jetables

Expand Down
3 changes: 3 additions & 0 deletions clevercloud/pre_build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
git clone "$ITOU_SECRETS_HTTPS_REPO_URL" secrets-vault
sops -d secrets-vault/c3/"$ENVIRONMENT".enc.env > .env

# generate requirements file to let clevercloud know which packages to install
uv export --format requirements-txt --no-dev --frozen > requirements.txt
2 changes: 1 addition & 1 deletion lacommunaute/forum_moderation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def create_from_post(cls, post, reason: BlockedPostReason):
"""
Creates a BlockedPost object from parameterised Post (machina)
"""
if type(reason) != BlockedPostReason:
if not isinstance(reason, BlockedPostReason):
raise TypeError("Reason must be a BlockedPostReason")

return cls.objects.create(
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/surveys/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import tomllib
from pathlib import Path

import tomllib
from django.apps import AppConfig
from django.db import models

Expand Down
Loading
Loading