From b24f253a3a2e66d87c7e7f7a9c6d06eaa9005f73 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 25 Sep 2026 02:54:44 -0400 Subject: [PATCH] [FIX] poetry update: run poetry in the Odoo venv, not the active one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Poetry works in the active virtualenv when VIRTUAL_ENV is set. Launched from a shell under .venv.erplibre, poetry add and poetry lock inherited its Python, outside the pyproject bounds, and failed with InvalidCurrentPythonVersionError. Both calls now activate the Odoo venv of the ERPLibre version, as install_locally.sh already does. Checked: poetry env info -p reports .venv.erplibre before, the Odoo venv after, for the shell script and for the Python call alike. --- FR --- [FIX] poetry update : poetry dans le venv Odoo, pas dans le venv actif Poetry travaille dans le virtualenv actif quand VIRTUAL_ENV est posé. Lancés d'un shell sous .venv.erplibre, poetry add et poetry lock en héritaient le Python, hors des bornes du pyproject, et échouaient sur InvalidCurrentPythonVersionError. Les deux appels activent désormais le venv Odoo de la version ERPLibre, comme le fait déjà install_locally.sh. Vérifié : poetry env info -p donne .venv.erplibre avant, le venv Odoo après, pour le script shell comme pour l'appel Python. Assisted-by: Claude Opus 5.5 --- script/poetry/poetry_add_build_dependency.sh | 4 ++++ script/poetry/poetry_update.py | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/script/poetry/poetry_add_build_dependency.sh b/script/poetry/poetry_add_build_dependency.sh index 3aedc13..be32cd4 100755 --- a/script/poetry/poetry_add_build_dependency.sh +++ b/script/poetry/poetry_add_build_dependency.sh @@ -22,6 +22,10 @@ if [[ ${#DEPS[@]} -eq 0 ]]; then exit 0 fi +# poetry travaille dans le venv actif s'il y en a un : sans cette activation, +# un shell sous .venv.erplibre lui imposerait un Python hors des bornes du +# pyproject (InvalidCurrentPythonVersionError). +source "${VENV}/bin/activate" "${VENV}/bin/poetry" add -vv "${DEPS[@]}" retVal=$? if [[ $retVal -ne 0 ]]; then diff --git a/script/poetry/poetry_update.py b/script/poetry/poetry_update.py index 5b20823..7354531 100755 --- a/script/poetry/poetry_update.py +++ b/script/poetry/poetry_update.py @@ -8,6 +8,7 @@ import logging import os import re import shutil +import subprocess import sys from collections import OrderedDict, defaultdict from pathlib import Path @@ -627,9 +628,14 @@ def call_poetry_lock(config): """ :return: True if success """ - venv_dir = f".venv.{config.set_version_erplibre}" - status = os.system(f"./{venv_dir}/bin/poetry lock") - return status == 0 + venv_dir = os.path.abspath(f".venv.{config.set_version_erplibre}") + # poetry works in the active venv when there is one: the caller's + # VIRTUAL_ENV (often .venv.erplibre) would hand it a Python outside the + # pyproject bounds, so the Odoo venv is activated for this call. + env = dict(os.environ, VIRTUAL_ENV=venv_dir) + env["PATH"] = os.pathsep.join([f"{venv_dir}/bin", env.get("PATH", "")]) + status = subprocess.run([f"{venv_dir}/bin/poetry", "lock"], env=env) + return status.returncode == 0 def call_poetry_add_build_dependency():