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():