[FIX] poetry update: run poetry in the Odoo venv, not the active one

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
This commit is contained in:
Mathieu Benoit 2026-09-25 02:54:44 -04:00
parent 2a5e83b5c7
commit b24f253a3a
2 changed files with 13 additions and 3 deletions

View file

@ -22,6 +22,10 @@ if [[ ${#DEPS[@]} -eq 0 ]]; then
exit 0 exit 0
fi 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[@]}" "${VENV}/bin/poetry" add -vv "${DEPS[@]}"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then

View file

@ -8,6 +8,7 @@ import logging
import os import os
import re import re
import shutil import shutil
import subprocess
import sys import sys
from collections import OrderedDict, defaultdict from collections import OrderedDict, defaultdict
from pathlib import Path from pathlib import Path
@ -627,9 +628,14 @@ def call_poetry_lock(config):
""" """
:return: True if success :return: True if success
""" """
venv_dir = f".venv.{config.set_version_erplibre}" venv_dir = os.path.abspath(f".venv.{config.set_version_erplibre}")
status = os.system(f"./{venv_dir}/bin/poetry lock") # poetry works in the active venv when there is one: the caller's
return status == 0 # 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(): def call_poetry_add_build_dependency():