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 file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
|
||||||
|
import importlib.metadata
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@@ -14,22 +15,35 @@ root = os.path.dirname(os.path.dirname(__file__))
|
|||||||
module_path = os.path.join(root, 'modules')
|
module_path = os.path.join(root, 'modules')
|
||||||
|
|
||||||
dependencies = set()
|
dependencies = set()
|
||||||
development_dependencies = {
|
build_dependencies = {
|
||||||
|
'rnc2rng',
|
||||||
'Babel',
|
'Babel',
|
||||||
|
'hatchling',
|
||||||
|
'hatch-tryton',
|
||||||
|
}
|
||||||
|
development_dependencies = build_dependencies | {
|
||||||
'Sphinx',
|
'Sphinx',
|
||||||
'cookiecutter',
|
'cookiecutter',
|
||||||
'rnc2rng',
|
|
||||||
'sphinx-lint',
|
'sphinx-lint',
|
||||||
'tox',
|
'tox',
|
||||||
}
|
}
|
||||||
|
|
||||||
FNULL = open(os.devnull, 'w')
|
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):
|
def add_dependencies(package):
|
||||||
|
cmd = 'python3 -m build -qq --metadata'
|
||||||
|
if _build_deps_installed:
|
||||||
|
cmd += ' --no-isolation'
|
||||||
metadata = subprocess.check_output(
|
metadata = subprocess.check_output(
|
||||||
'python3 -m build -n -q --metadata',
|
cmd, shell=True, encoding='utf-8', cwd=package).strip()
|
||||||
shell=True, encoding='utf-8', cwd=package).strip()
|
|
||||||
metadata = json.loads(metadata)
|
metadata = json.loads(metadata)
|
||||||
for requirement in metadata.get('requires_dist', []):
|
for requirement in metadata.get('requires_dist', []):
|
||||||
requirement = Requirement(requirement)
|
requirement = Requirement(requirement)
|
||||||
|
|||||||
Reference in New Issue
Block a user