From 86800a983040f96e89877b7a735fcab764d1c47c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20D=C3=ADaz=20Miralles?= Date: Thu, 26 Mar 2026 22:39:31 +0100 Subject: [PATCH] Do not use isolation in update_requirements hook unless necessary Closes #14707 --- .hooks/update_requirements | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.hooks/update_requirements b/.hooks/update_requirements index 497bec0ed4..f47ed2d06b 100755 --- a/.hooks/update_requirements +++ b/.hooks/update_requirements @@ -2,6 +2,7 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. +import importlib.metadata import io import json import os @@ -14,22 +15,35 @@ root = os.path.dirname(os.path.dirname(__file__)) module_path = os.path.join(root, 'modules') dependencies = set() -development_dependencies = { +build_dependencies = { + 'rnc2rng', 'Babel', + 'hatchling', + 'hatch-tryton', + } +development_dependencies = build_dependencies | { 'Sphinx', 'cookiecutter', - 'rnc2rng', 'sphinx-lint', 'tox', } FNULL = open(os.devnull, 'w') +_build_deps_installed = True +try: + for requirement in build_dependencies: + importlib.metadata.version(Requirement(requirement).name) +except importlib.metadata.PackageNotFoundError: + _build_deps_installed = False + def add_dependencies(package): + cmd = 'python3 -m build -qq --metadata' + if _build_deps_installed: + cmd += ' --no-isolation' metadata = subprocess.check_output( - 'python3 -m build -n -q --metadata', - shell=True, encoding='utf-8', cwd=package).strip() + cmd, shell=True, encoding='utf-8', cwd=package).strip() metadata = json.loads(metadata) for requirement in metadata.get('requires_dist', []): requirement = Requirement(requirement)