Do not use isolation in update_requirements hook unless necessary
Closes #14707
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user