details: https://code.tryton.org/hatch-tryton/commit/28efa9994a0e
branch: default
user: Cédric Krier <[email protected]>
date: Thu Mar 12 17:48:56 2026 +0100
description:
Add module extras depend as optional-dependencies for test
diffstat:
hatch_tryton/plugin.py | 11 +++++++-
hatch_tryton/tests/test_metadata.py | 47 +++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 1 deletions(-)
diffs (92 lines):
diff -r 1230d65e2022 -r 28efa9994a0e hatch_tryton/plugin.py
--- a/hatch_tryton/plugin.py Thu Mar 12 14:27:44 2026 +0100
+++ b/hatch_tryton/plugin.py Thu Mar 12 17:48:56 2026 +0100
@@ -10,7 +10,8 @@
from hatchling.metadata.plugin.interface import MetadataHookInterface
-TrytonConfig = namedtuple('TrytonConfig', ['version', 'depends'])
+TrytonConfig = namedtuple(
+ 'TrytonConfig', ['version', 'depends', 'extras_depend'])
Author = namedtuple('Author', ['name', 'email'])
_COPYRIGHT_PREFIX = "Copyright (C) "
@@ -26,6 +27,8 @@
version=config.get('tryton', 'version'),
depends=config.get(
'tryton', 'depends', fallback='').strip().splitlines(),
+ extras_depend=config.get(
+ 'tryton', 'extras_depend', fallback='').strip().splitlines(),
)
@@ -116,6 +119,12 @@
optional_dependencies = self.config.get('optional-dependencies', {})
+ if tryton_cfg and tryton_cfg.extras_depend:
+ test_depends = optional_dependencies.setdefault('test', [])
+ for module in tryton_cfg.extras_depend:
+ package = _package_name(module, prefixes)
+ test_depends.append(_set_version(package, series))
+
if tryton_optional_dependencies := self.config.get(
'tryton-optional-dependencies', {}):
for option, packages in tryton_optional_dependencies.items():
diff -r 1230d65e2022 -r 28efa9994a0e hatch_tryton/tests/test_metadata.py
--- a/hatch_tryton/tests/test_metadata.py Thu Mar 12 14:27:44 2026 +0100
+++ b/hatch_tryton/tests/test_metadata.py Thu Mar 12 17:48:56 2026 +0100
@@ -174,6 +174,53 @@
metadata.get('optional-dependencies', {}).get('option', []))
@with_temporay_directory
+ def test_module_extra_dependencies(self, directory: Path):
+ "Test module extra dependencies"
+ config = {}
+ metadata = {
+ 'dynamic': ['optional-dependencies'],
+ }
+ (directory / 'tryton.cfg').write_text(dedent("""\
+ [tryton]
+ version=1.0.0
+ extras_depend:
+ other_module
+ """))
+ hook = TrytonMetadataHook(directory, config)
+ hook.update(metadata)
+ self.assertEqual({
+ 'test': ['trytond_other_module >= 1.0, < 1.1'],
+ },
+ metadata.get('optional-dependencies', {}))
+
+ @with_temporay_directory
+ def test_module_extra__tryton_optional_dependencies(self, directory: Path):
+ "Test module extra and Tryton optional dependencies"
+ config = {
+ 'tryton-optional-dependencies': {
+ 'test': ['module'],
+ },
+ }
+ metadata = {
+ 'dynamic': ['optional-dependencies'],
+ }
+ (directory / 'tryton.cfg').write_text(dedent("""\
+ [tryton]
+ version=1.0.0
+ extras_depend:
+ other_module
+ """))
+ hook = TrytonMetadataHook(directory, config)
+ hook.update(metadata)
+ self.assertEqual({
+ 'test': [
+ 'trytond_other_module >= 1.0, < 1.1',
+ 'module >= 1.0, < 1.1',
+ ],
+ },
+ metadata.get('optional-dependencies', {}))
+
+ @with_temporay_directory
def test_optional_dependencies_not_dynamic(self, directory: Path):
"Test optional-dependencies not dynamic"
config = {