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

Conversation

vincentporte
Copy link
Contributor

@vincentporte vincentporte commented Jan 7, 2025

Description

🎸 utiliser uv pour la gestion des environnements virtuels et la gestion des dépendances
🎸 le fichier requirements.txt requis par le PAAS clevercloud est généré à partir du fichier uv.lock versionné, lors du déploiement.

Type de changement

🚧 technique

Points d'attention

🦺 suppression du versionning des fichiers requirements.txt
🦺 le script pre_build.sh est chargé de généré le fichier requirements.txt
🦺 les paramètres de uv export :
* --format requirements-txt : export au format avec les hashes des dépendances
* --no-dev : ignorer les dependances du groupe dev
* --frozen : ne pas mettre à jour uv.lock avant l'export

⚠️ mise à jour des variables d'environnement du PAAS

CC_PIP_REQUIREMENTS_FILE="./requirements.txt"
UV_PROJECT_ENVIRONMENT="/home/bas/venv"

🦺 export du chemin de l'environnement virtuel dans ci.yml pour que les étapes suivantes accèdent aux dépendances installées

@vincentporte vincentporte linked an issue Jan 7, 2025 that may be closed by this pull request
@vincentporte vincentporte added dependencies Pull requests that update a dependency file technical debt labels Jan 7, 2025
@vincentporte vincentporte added the recette-jetable review_app label Jan 7, 2025
@vincentporte
Copy link
Contributor Author

vincentporte commented Jan 7, 2025

ajout de UV_PROJECT_ENVIRONMENT="/home/bas/venv" dans l'addon clever

=> résout l'erreur sur l'environnement virtuel

@vincentporte
Copy link
Contributor Author

vincentporte commented Jan 7, 2025

2025-01-07T16:37:19.996Z ./requirements.txt found, using pip...
2025-01-07T16:37:21.755Z Obtaining file:///home/bas/app_62fb5d9c-596a-4a3c-bb7f-faf3d61d8ac7 (from -r ./requirements.txt (line 3))
2025-01-07T16:37:21.943Z ERROR: The editable requirement file:///home/bas/app_62fb5d9c-596a-4a3c-bb7f-faf3d61d8ac7 (from -r ./requirements.txt (line 3)) cannot be installed when requiring hashes, because there is no single file to hash.

@vincentporte
Copy link
Contributor Author

2025-01-07T16:47:38.291Z Running CC_PRE_BUILD_HOOK: ./clevercloud/pre_build.sh
2025-01-07T16:47:39.442Z Cloning into 'secrets-vault'...
2025-01-07T16:47:40.736Z Resolved 111 packages in 36ms
2025-01-07T16:48:05.481Z Prepared 110 packages in 24.73s
2025-01-07T16:48:06.302Z Installed 110 packages in 819ms
2025-01-07T16:48:06.304Z  + anyio==4.8.0
2025-01-07T16:48:06.304Z  + asgiref==3.8.1
[…]
2025-01-07T16:48:06.313Z  + webencodings==0.5.1
2025-01-07T16:48:06.313Z  + werkzeug==3.1.3
2025-01-07T16:48:06.313Z  + wrapt==1.17.0
2025-01-07T16:48:06.313Z  + xmltodict==0.14.2
2025-01-07T16:48:06.368Z Resolved 111 packages in 3ms
2025-01-07T16:48:06.382Z # This file was autogenerated by uv via the following command:
2025-01-07T16:48:06.382Z #    uv export --format requirements-txt --no-dev
2025-01-07T16:48:06.382Z -e .
2025-01-07T16:48:06.382Z anyio==4.8.0 \
2025-01-07T16:48:06.382Z     --hash=sha256:1d9fe889df5212298c0c0723fa20479d1b94883a2df44bd3897aa91083316f7a \
2025-01-07T16:48:06.382Z     --hash=sha256:b5011f270ab5eb0abf13385f851315585cc37ef330dd88e27ec3d34d651fd47a
2025-01-07T16:48:06.382Z asgiref==3.8.1 \
2025-01-07T16:48:06.382Z     --hash=sha256:3e1e3ecc849832fe52ccf2cb6686b7a55f82bb1d6aee72a58826471390335e47 \
2025-01-07T16:48:06.382Z     --hash=sha256:c343bd80a0bec947a9860adb4c432ffa7db769836c64238fc34bdc3fec84d590
2025-01-07T16:48:06.382Z boto3==1.35.93 \
2025-01-07T16:48:06.382Z     --hash=sha256:2446e819cf4e295833474cdcf2c92bc82718ce537e9ee1f17f7e3d237f60e69b \
2025-01-07T16:48:06.382Z     --hash=sha256:7de2c44c960e486f3c57e5203ea6393c6c4f0914c5f81c789ceb8b5d2ba5d1c5
[…]
2025-01-07T16:48:06.395Z tzdata==2024.2 ; sys_platform == 'win32' \
2025-01-07T16:48:06.395Z     --hash=sha256:7d85cc416e9382e69095b7bdf4afd9e3880418a2413feec7069d533d6b4e31cc \
2025-01-07T16:48:06.395Z     --hash=sha256:a48093786cdcde33cad18c2555e8532f34422074448fbc874186f0abd79565cd
2025-01-07T16:48:06.395Z urllib3==2.3.0 \
2025-01-07T16:48:06.395Z     --hash=sha256:1cee9ad369867bfdbbb48b7dd50374c0967a0bb7710050facf0dd6911440e3df \
2025-01-07T16:48:06.395Z     --hash=sha256:f8c5449b3cf0861679ce7e0503c7b44b5ec981bec0d1d3795a07f1ba96f0204d
2025-01-07T16:48:07.878Z ./requirements.txt found, using pip...
2025-01-07T16:48:09.127Z Obtaining file:///home/bas/app_62fb5d9c-596a-4a3c-bb7f-faf3d61d8ac7 (from -r ./requirements.txt (line 3))
2025-01-07T16:48:09.240Z ERROR: The editable requirement file:///home/bas/app_62fb5d9c-596a-4a3c-bb7f-faf3d61d8ac7 (from -r ./requirements.txt (line 3)) cannot be installed when requiring hashes, because there is no single file to hash.
2025-01-07T16:48:09.303Z Build failed. Please check the logs above

@vincentporte
Copy link
Contributor Author

exec pwd then ls

2025-01-07T16:52:30.808Z /home/bas/app_62fb5d9c-596a-4a3c-bb7f-faf3d61d8ac7
2025-01-07T16:52:30.811Z CHANGELOG.md
2025-01-07T16:52:30.811Z LICENSE
2025-01-07T16:52:30.811Z Makefile
2025-01-07T16:52:30.811Z README.md
2025-01-07T16:52:30.811Z clevercloud
2025-01-07T16:52:30.811Z config
2025-01-07T16:52:30.811Z docker
2025-01-07T16:52:30.811Z docker-compose.yml
2025-01-07T16:52:30.811Z fixtures
2025-01-07T16:52:30.811Z lacommunaute
2025-01-07T16:52:30.811Z locale
2025-01-07T16:52:30.811Z manage.py
2025-01-07T16:52:30.811Z pyproject.toml
2025-01-07T16:52:30.811Z requirements.txt
2025-01-07T16:52:30.811Z scripts
2025-01-07T16:52:30.811Z secrets-vault
2025-01-07T16:52:30.811Z setup.cfg
2025-01-07T16:52:30.811Z uv.lock
2025-01-07T16:52:32.360Z ./requirements.txt found, using pip...
2025-01-07T16:52:33.677Z Obtaining file:///home/bas/app_62fb5d9c-596a-4a3c-bb7f-faf3d61d8ac7 (from -r ./requirements.txt (line 3))
2025-01-07T16:52:33.831Z ERROR: The editable requirement file:///home/bas/app_62fb5d9c-596a-4a3c-bb7f-faf3d61d8ac7 (from -r ./requirements.txt (line 3)) cannot be installed when requiring hashes, because there is no single file to hash.
2025-01-07T16:52:33.892Z Build failed. Please check the logs above

@vincentporte vincentporte added recette-jetable review_app and removed recette-jetable review_app labels Jan 7, 2025
Copy link
Contributor

github-actions bot commented Jan 7, 2025

🥁 La recette jetable est prête ! 👉 Je veux tester cette PR !

@vincentporte
Copy link
Contributor Author

vincentporte commented Jan 7, 2025

fichier requirements.txt généré par uv export --format requirements-txt

# This file was autogenerated by uv via the following command:
#    uv export --no-dev --format requirements-txt
-e .
anyio==4.8.0 \
[…]

-e . en ligne 3 fait planter la prise en compte par clever

=> le parametre --not-editable est un bon candidat pour regler ce point

@vincentporte vincentporte added recette-jetable review_app and removed recette-jetable review_app labels Jan 7, 2025
@vincentporte
Copy link
Contributor Author

vincentporte commented Jan 8, 2025

uv sync
uv export --format requirements-txt --no-dev --no-editable > requirements.txt

dans pre_build.sh

résultat 🔴

2025-01-08T07:34:05.873Z: Resolved 111 packages in 2ms
2025-01-08T07:34:07.895Z: ./requirements.txt found, using pip...
2025-01-08T07:34:09.725Z: Processing /home/bas/app_233df755-2ba6-434d-aae4-66a9a01448f4
2025-01-08T07:34:09.889Z: ERROR: Can't verify hashes for these file:// requirements because they point to directories:
2025-01-08T07:34:09.889Z:     file:///home/bas/app_233df755-2ba6-434d-aae4-66a9a01448f4 (from -r ./requirements.txt (line 3))
2025-01-08T07:34:09.990Z: Build failed. Please check the logs above
2025-01-08T07:34:09.991Z: Deploy failed

début du fichier requirements.txt généré

# This file was autogenerated by uv via the following command:
#    uv export --format requirements-txt --no-dev --no-editable
.
anyio==4.8.0 \
    --hash=sha256:1d9fe889df5212298c0c0723fa20479d1b94883a2df44bd3897aa91083316f7a \
    --hash=sha256:b5011f270ab5eb0abf13385f851315585cc37ef330dd88e27ec3d34d651fd47a
asgiref==3.8.1 \
[#342 

toujours un sujet avec la ligne 3 ?

@vincentporte vincentporte added recette-jetable review_app and removed recette-jetable review_app labels Jan 8, 2025
Copy link
Contributor

github-actions bot commented Jan 8, 2025

🥁 La recette jetable est prête ! 👉 Je veux tester cette PR !

@vincentporte vincentporte removed the recette-jetable review_app label Jan 8, 2025
@vincentporte vincentporte force-pushed the 874-remplacer-poetry-par-uv branch 2 times, most recently from befbb75 to cef0a4e Compare January 8, 2025 08:35
@vincentporte vincentporte added the recette-jetable review_app label Jan 8, 2025
Copy link
Contributor

github-actions bot commented Jan 8, 2025

🥁 La recette jetable est prête ! 👉 Je veux tester cette PR !

@vincentporte vincentporte added recette-jetable review_app and removed recette-jetable review_app labels Jan 8, 2025
Copy link
Contributor

github-actions bot commented Jan 8, 2025

🥁 La recette jetable est prête ! 👉 Je veux tester cette PR !

@vincentporte vincentporte added recette-jetable review_app and removed recette-jetable review_app labels Jan 8, 2025
Copy link
Contributor

github-actions bot commented Jan 8, 2025

🥁 La recette jetable est prête ! 👉 Je veux tester cette PR !

@vincentporte vincentporte removed the recette-jetable review_app label Jan 8, 2025
@vincentporte vincentporte force-pushed the 874-remplacer-poetry-par-uv branch 5 times, most recently from 4c33e0d to 54c1301 Compare January 8, 2025 15:01
@vincentporte vincentporte marked this pull request as ready for review January 8, 2025 15:14
pyproject.toml Outdated
name = "lacommunaute"
version = "2.19.0"
description = "La communauté de l'inclusion"
authors = []
license = "ETALAB 2.0"
license = {text = "ETALAB 2.0"}
requires-python = "~=3.11"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
requires-python = "~=3.11"
requires-python = "~=3.12"

line_length = 119
[dependency-groups]
dev = [
"black>=24.3.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus nécessaire ?

dependencies = [
"Django>=5.0",
"python-dotenv>=0.21.0",
"psycopg2-binary>=2.9.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je ne pense pas que la version binaire soit nécessaire ?

@vincentporte vincentporte force-pushed the 874-remplacer-poetry-par-uv branch from 54c1301 to 943eb06 Compare January 9, 2025 13:00
@vincentporte vincentporte force-pushed the 874-remplacer-poetry-par-uv branch from 943eb06 to 9eec8c3 Compare January 9, 2025 15:07
@vincentporte vincentporte merged commit 3904f46 into master Jan 13, 2025
8 checks passed
@vincentporte vincentporte deleted the 874-remplacer-poetry-par-uv branch January 13, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

remplacer Poetry par UV
3 participants