From 29e236de9766b1f9812ef38e4698856f142c48f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Arturo=20Garci=CC=81a?= Date: Wed, 30 Sep 2026 18:49:33 -0400 Subject: [PATCH] Use setuptools packaging for Tryton 7.0 --- .gitea/workflows/publish.yml | 4 +- doc/conf.py | 17 ++------- pyproject.toml | 69 --------------------------------- setup.py | 74 ++++++++++++++++++++++++++++++++++++ tests/test_module.py | 27 ++++++------- tox.ini | 2 +- 6 files changed, 92 insertions(+), 101 deletions(-) delete mode 100644 pyproject.toml create mode 100644 setup.py diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml index dc8bffe..d20f631 100644 --- a/.gitea/workflows/publish.yml +++ b/.gitea/workflows/publish.yml @@ -71,7 +71,6 @@ jobs: import json import os import re - import tomllib OWNER = 'tryton-do' PACKAGE_TYPE = 'pypi' @@ -89,8 +88,7 @@ jobs: series = os.environ['PACKAGE_SERIES'] major, minor = map(int, series.split('.')) - pyproject = tomllib.loads(Path('pyproject.toml').read_text()) - package_name = pyproject['project']['name'] + package_name = 'unpaismejor_account_do' normalized_name = normalize(package_name) username = os.environ['TWINE_USERNAME'] diff --git a/doc/conf.py b/doc/conf.py index 8b34c62..aa566d5 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -14,31 +14,22 @@ else: def get_info(): import configparser - import json - import subprocess - module_dir = os.path.dirname(os.path.dirname(__file__)) config = configparser.ConfigParser() config.read_file(open(os.path.join(module_dir, 'tryton.cfg'))) info = dict(config.items('tryton')) - metadata_cmd = 'python3 -m build -qq --metadata' - if os.environ.get('DOC_NO_ISOLATION'): - metadata_cmd += ' --no-isolation' - metadata = subprocess.check_output( - metadata_cmd, shell=True, encoding='utf-8', cwd=module_dir).strip() - metadata = json.loads(metadata) - info['name'] = metadata['name'] - info['description'] = metadata['summary'] - major_version, minor_version, _ = metadata['version'].split('.', 2) + info['name'] = 'unpaismejor_account_do' + info['description'] = 'Dominican Republic accounting for Tryton' + major_version, minor_version, _ = info['version'].split('.', 2) major_version = int(major_version) minor_version = int(minor_version) if minor_version % 2: info['series'] = 'latest' info['branch'] = 'branch/default' else: - info['series'] = '.'.join(metadata['version'].split('.', 2)[:2]) + info['series'] = '.'.join(info['version'].split('.', 2)[:2]) info['branch'] = 'branch/' + info['series'] for key in {'depends', 'extras_depend'}: diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index aeef567..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,69 +0,0 @@ -[build-system] -requires = ['hatchling >= 1', 'hatch-tryton'] -build-backend = 'hatchling.build' - -[project] -name = 'unpaismejor_account_do' -dynamic = ['version', 'dependencies', 'optional-dependencies', 'authors', 'readme'] -requires-python = '>=3.10' -maintainers = [ - {name = "Fundación Un País Mejor"}, - ] -description = "Dominican Republic accounting for Tryton" -license = 'GPL-3.0-or-later' -license-files = ['LICENSE', 'COPYRIGHT'] -keywords = ["tryton", "accounting", "coa", "dominican-republic"] -classifiers = [ - "Development Status :: 5 - Production/Stable", - "Environment :: Plugins", - "Framework :: Tryton", - "Topic :: Office/Business", - "Topic :: Office/Business :: Financial :: Accounting", - "Topic :: Software Development :: Libraries :: Python Modules", - ] - -[project.entry-points.'trytond.modules'] -account_do = 'trytond.modules.account_do' - -[project.urls] -homepage = "https://www.unpaismejor.org.do" -documentation = "https://docs.tryton.org/modules-account-do/" -changelog = "https://docs.tryton.org/modules-account-do/releases.html" -forum = "https://www.tryton.org/forum" -issues = "https://bugs.tryton.org/tryton" -repository = "https://code.unpaismejor.org.do/tryton-do/account_do" -funding = "https://www.tryton.org/donate" - -[tool.hatch.build] -include = [ - 'README.rst', - 'CHANGELOG', - 'pyproject.toml', - '**/tryton.cfg', - '**/*.py', - '**/*.xml', - '**/*.po', - 'doc/**/*.rst', - 'doc/**/*.py', - 'view/**/*.xml', - '**/*.fodt', - 'icons/**/*.svg', - 'tests/**/*.rst', - 'tests/**/*.json', - ] - -[tool.hatch.build.targets.wheel.sources] -"" = "trytond/modules/account_do" - -[tool.hatch.metadata.hooks.tryton] -dependencies = [] -copyright = 'COPYRIGHT' -readme = 'README.rst' - -[tool.hatch.metadata.hooks.tryton.tryton-optional-dependencies] -test = [ - 'proteus', - 'trytond-account-asset', - 'trytond-account-deposit', - 'trytond-account-stock-continental', - ] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e5d62e7 --- /dev/null +++ b/setup.py @@ -0,0 +1,74 @@ +from configparser import ConfigParser +from pathlib import Path + +from setuptools import setup + + +MODULE = 'account_do' +PREFIX = 'trytond.modules' +PACKAGE = f'{PREFIX}.{MODULE}' + + +def read(path): + return Path(path).read_text(encoding='utf-8') + + +config = ConfigParser() +config.read('tryton.cfg') +version = config.get('tryton', 'version') +major, minor, _ = version.split('.', 2) +series = f'{major}.{minor}' +next_major = f'{major}.{int(minor) + 1}' + + +setup( + name='unpaismejor_account_do', + version=version, + description='Dominican Republic accounting for Tryton', + long_description=read('README.rst'), + long_description_content_type='text/x-rst', + author='Fundación Un País Mejor', + maintainer='Fundación Un País Mejor', + url='https://code.unpaismejor.org.do/tryton-do/account_do', + keywords='tryton accounting coa dominican-republic', + license='GPL-3.0-or-later', + python_requires='>=3.8', + packages=[PACKAGE], + package_dir={PACKAGE: '.'}, + package_data={ + PACKAGE: [ + 'tryton.cfg', + '*.xml', + 'view/*.xml', + 'locale/*.po', + 'doc/*.rst', + ], + }, + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Plugins', + 'Framework :: Tryton', + 'Topic :: Office/Business', + 'Topic :: Office/Business :: Financial :: Accounting', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + install_requires=[ + f'trytond >= {series}, < {next_major}', + f'trytond_account >= {series}, < {next_major}', + f'trytond_account_invoice >= {series}, < {next_major}', + ], + extras_require={ + 'test': [ + f'proteus >= {series}, < {next_major}', + f'trytond_account_asset >= {series}, < {next_major}', + f'trytond_account_deposit >= {series}, < {next_major}', + f'trytond_account_stock_continental >= {series}, < {next_major}', + ], + }, + entry_points={ + 'trytond.modules': [ + f'{MODULE} = {PACKAGE}', + ], + }, + zip_safe=False, +) diff --git a/tests/test_module.py b/tests/test_module.py index 1ee9e22..b147c37 100644 --- a/tests/test_module.py +++ b/tests/test_module.py @@ -652,27 +652,24 @@ class AccountDoUnitTestCase(unittest.TestCase): self.assertTrue((MODULE_DIR / filename).is_file()) self.assertTrue((MODULE_DIR / 'account.py').is_file()) self.assertTrue((MODULE_DIR / 'tax.py').is_file()) - pyproject = (MODULE_DIR / 'pyproject.toml').read_text(encoding='utf-8') - self.assertIn("name = 'unpaismejor_account_do'", pyproject) + setup_py = (MODULE_DIR / 'setup.py').read_text(encoding='utf-8') + self.assertIn("name='unpaismejor_account_do'", setup_py) self.assertIn( - "account_do = 'trytond.modules.account_do'", pyproject) + "f'{MODULE} = {PACKAGE}'", setup_py) self.assertIn( - '{name = "Fundación Un País Mejor"}', pyproject) + "maintainer='Fundación Un País Mejor'", setup_py) self.assertIn( - 'homepage = "https://www.unpaismejor.org.do"', pyproject) + "url='https://code.unpaismejor.org.do/tryton-do/account_do'", + setup_py) self.assertIn( - ('repository = "https://code.unpaismejor.org.do/' - 'tryton-do/account_do"'), pyproject) + "python_requires='>=3.8'", setup_py) for package_file in [ - "'README.rst'", - "'CHANGELOG'", - "'pyproject.toml'", - "'**/*.xml'", - "'**/*.po'", - "'doc/**/*.rst'", - "'tests/**/*.rst'", + "'*.xml'", + "'view/*.xml'", + "'locale/*.po'", + "'doc/*.rst'", ]: - self.assertIn(package_file, pyproject) + self.assertIn(package_file, setup_py) for filename in [ '__init__.py', 'account.py', diff --git a/tox.ini b/tox.ini index 01e91a6..9316bfc 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = {py310,py311,py312,py313,py314}-{sqlite,postgresql} +envlist = {py38,py39,py310,py311}-{sqlite,postgresql} [testenv] changedir = {env_site_packages_dir}