From 6115895e94b078476994b31a6a0653ab7ccc1d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juancarlo=20A=C3=B1ez?= Date: Sun, 15 Oct 2023 18:52:03 -0400 Subject: [PATCH] [build] move setup.cfg configuration to pyproject.toml (#317) * [imports] change to relative imports * [build] remove setup.cfg use pyproject.toml only * [build] include pyproject.toml in MANIFEST --- MANIFEST.in | 1 + pyproject.toml | 41 +++++++++++++++++++++++++++++++++++++++++ setup.cfg | 46 ---------------------------------------------- tatsu/__init__.py | 6 +++--- tatsu/ast.py | 2 +- tatsu/contexts.py | 4 ++-- tatsu/diagrams.py | 2 +- tatsu/grammars.py | 2 +- tatsu/model.py | 12 ++++++------ tatsu/parsing.py | 6 +++--- tatsu/rendering.py | 2 +- tatsu/semantics.py | 10 +++++----- tatsu/symtables.py | 7 +++---- tatsu/tool.py | 16 ++++++++-------- tatsu/walkers.py | 4 ++-- 15 files changed, 78 insertions(+), 83 deletions(-) delete mode 100644 setup.cfg diff --git a/MANIFEST.in b/MANIFEST.in index 3cba2c1c..3c5b2591 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,6 +4,7 @@ include *.ini include *.md include *.rst include *.txt +include *.toml include *.yaml include Makefile diff --git a/pyproject.toml b/pyproject.toml index 205a289e..86953a40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,44 @@ [build-system] requires = ["setuptools>=46.4", "wheel"] build-backend = "setuptools.build_meta" + +[project] +name = "TatSu" +dynamic = ["version"] +authors = [ + {name = "Juancarlo Añez", email = "apalala@gmail.com"}, +] +description = "TatSu takes a grammar in a variation of EBNF as input, and outputs a memoizing PEG/Packrat parser in Python." +readme = "README.rst" +requires-python = ">=3.11" +keywords = [] +license = {file = "LICENSE.TXT"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Environment :: Console", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Code Generators", + "Topic :: Software Development :: Compilers", + "Topic :: Software Development :: Interpreters", + "Topic :: Text Processing :: General", +] +dependencies = [] + +[project.optional-dependencies] +colorization = ["colorama"] + +[project.scripts] +tatsu = "tatsu:main" +g2e = "tatsu.g2e:main" + +[tool.setuptools] +packages = ["tatsu"] + +[tool.setuptools.dynamic] +version = {attr = "tatsu._version.__version__"} diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index f39fb3d2..00000000 --- a/setup.cfg +++ /dev/null @@ -1,46 +0,0 @@ -[metadata] -name = TatSu -version = attr: tatsu.__version__ -author = Juancarlo Añez -author_email = apalala@gmail.com -maintainer = Juancarlo Añez -maintainer_email = apalala@gmail.com -license = BSD-3-Clause-Attribution -description = TatSu takes a grammar in a variation of EBNF as input, and outputs a memoizing PEG/Packrat parser in Python. -url = https://github.com/neogeny/tatsu -long_description = file: README.rst -classifiers = - Development Status :: 5 - Production/Stable - License :: OSI Approved :: BSD License - Natural Language :: English - Intended Audience :: Developers - Intended Audience :: Science/Research - Environment :: Console - Operating System :: OS Independent - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Topic :: Software Development :: Code Generators - Topic :: Software Development :: Compilers - Topic :: Software Development :: Interpreters - Topic :: Text Processing :: General - -[options] -packages = find: -zip_safe = False -include_package_data = True -python_requires = >=3.11 -tests_require = pytest-mypy - -[options.entry_points] -console_scripts = - tatsu = tatsu:main - g2e = tatsu.g2e:main - -[options.extras_require] -future-regex = regex - -[bdist_wheel] -universal = 1 - -[aliases] -test = pytest diff --git a/tatsu/__init__.py b/tatsu/__init__.py index fc759bae..bd4d9588 100644 --- a/tatsu/__init__.py +++ b/tatsu/__init__.py @@ -1,8 +1,8 @@ from __future__ import annotations -from tatsu._config import __version__ -from tatsu._config import __toolname__ -from tatsu.tool import ( # pylint: disable=W0622 +from ._config import __version__ +from ._config import __toolname__ +from .tool import ( # pylint: disable=W0622 main, compile, parse, diff --git a/tatsu/ast.py b/tatsu/ast.py index c67873e8..12b9b842 100644 --- a/tatsu/ast.py +++ b/tatsu/ast.py @@ -3,7 +3,7 @@ import operator from functools import reduce -from tatsu.util import asjson, is_list +from .util import asjson, is_list class AST(dict): diff --git a/tatsu/contexts.py b/tatsu/contexts.py index f5d0f962..e1c8959a 100644 --- a/tatsu/contexts.py +++ b/tatsu/contexts.py @@ -6,7 +6,7 @@ from contextlib import contextmanager from copy import copy -from tatsu.util.unicode_characters import ( +from .util.unicode_characters import ( C_ENTRY, C_SUCCESS, C_FAILURE, @@ -30,7 +30,7 @@ ParseState, ParserConfig, ) -from tatsu.exceptions import ( # noqa pylint:disable=unused-import +from .exceptions import ( # noqa pylint:disable=unused-import FailedCut, FailedExpectingEndOfText, FailedLeftRecursion, diff --git a/tatsu/diagrams.py b/tatsu/diagrams.py index 399d9149..c6ea4ddd 100644 --- a/tatsu/diagrams.py +++ b/tatsu/diagrams.py @@ -4,7 +4,7 @@ import pygraphviz as pgv # pylint: disable=E0401 -from tatsu.walkers import NodeWalker +from .walkers import NodeWalker __all__ = ['draw'] diff --git a/tatsu/grammars.py b/tatsu/grammars.py index 6e1fc949..64c5e28e 100644 --- a/tatsu/grammars.py +++ b/tatsu/grammars.py @@ -7,7 +7,7 @@ from copy import copy from itertools import takewhile -from tatsu.util import ( +from .util import ( indent, trim, compress_seq, chunks, re, ) diff --git a/tatsu/model.py b/tatsu/model.py index 905a0d8d..b125cc0e 100755 --- a/tatsu/model.py +++ b/tatsu/model.py @@ -1,8 +1,8 @@ from __future__ import annotations -from tatsu.ast import AST # noqa: F401 -from tatsu.objectmodel import Node # noqa: F401 -from tatsu.objectmodel import Node as ParseModel # noqa: F401 -from tatsu.walkers import NodeWalker # noqa: F401 -from tatsu.walkers import DepthFirstWalker # noqa: F401 -from tatsu.semantics import ModelBuilderSemantics # noqa: F401 +from .ast import AST # noqa: F401 +from .objectmodel import Node # noqa: F401 +from .objectmodel import Node as ParseModel # noqa: F401 +from .walkers import NodeWalker # noqa: F401 +from .walkers import DepthFirstWalker # noqa: F401 +from .semantics import ModelBuilderSemantics # noqa: F401 diff --git a/tatsu/parsing.py b/tatsu/parsing.py index 481b8184..c1b710b2 100644 --- a/tatsu/parsing.py +++ b/tatsu/parsing.py @@ -2,9 +2,9 @@ import inspect -from tatsu.exceptions import FailedRef -from tatsu.contexts import ParseContext -from tatsu.contexts import tatsumasu, leftrec, nomemo, isname # noqa pylint: disable=unused-import +from .exceptions import FailedRef +from .contexts import ParseContext +from .contexts import tatsumasu, leftrec, nomemo, isname # noqa pylint: disable=unused-import class Parser(ParseContext): diff --git a/tatsu/rendering.py b/tatsu/rendering.py index fbfef7d7..7ab0546e 100644 --- a/tatsu/rendering.py +++ b/tatsu/rendering.py @@ -7,7 +7,7 @@ import itertools import string -from tatsu.util import indent, isiter, trim +from .util import indent, isiter, trim def render(item, join='', **fields): diff --git a/tatsu/semantics.py b/tatsu/semantics.py index 5f336e4b..9c3d6100 100644 --- a/tatsu/semantics.py +++ b/tatsu/semantics.py @@ -1,11 +1,11 @@ from __future__ import annotations import builtins -from tatsu.util import simplify_list -from tatsu.exceptions import SemanticError -from tatsu.objectmodel import Node -from tatsu.objectmodel import BASE_CLASS_TOKEN -from tatsu.synth import synthesize +from .util import simplify_list +from .exceptions import SemanticError +from .objectmodel import Node +from .objectmodel import BASE_CLASS_TOKEN +from .synth import synthesize class ASTSemantics: diff --git a/tatsu/symtables.py b/tatsu/symtables.py index b13314fd..6379376b 100644 --- a/tatsu/symtables.py +++ b/tatsu/symtables.py @@ -4,10 +4,9 @@ from copy import copy from collections import defaultdict -from tatsu.util import asjson -from tatsu.util import join_lists -from tatsu.exceptions import ParseException -from tatsu.infos import LineIndexInfo +from .util import asjson, join_lists +from .exceptions import ParseException +from .infos import LineIndexInfo DEFAULT_SEPARATOR = '.' diff --git a/tatsu/tool.py b/tatsu/tool.py index 62a476df..9fbd03d1 100644 --- a/tatsu/tool.py +++ b/tatsu/tool.py @@ -9,16 +9,16 @@ import sys import importlib -from tatsu._version import __version__ -from tatsu.util import eval_escapes -from tatsu.exceptions import ParseException -from tatsu.parser import GrammarGenerator -from tatsu.semantics import ModelBuilderSemantics -from tatsu.infos import ParserConfig +from ._version import __version__ +from .util import eval_escapes +from .exceptions import ParseException +from .parser import GrammarGenerator +from .semantics import ModelBuilderSemantics +from .infos import ParserConfig # we hook the tool to the Python code generator as the default -from tatsu.codegen.python import codegen as pythoncg -from tatsu.codegen import objectmodel +from .codegen.python import codegen as pythoncg +from .codegen import objectmodel DESCRIPTION = ( 'TatSu takes a grammar' diff --git a/tatsu/walkers.py b/tatsu/walkers.py index 8b515e91..072761f1 100644 --- a/tatsu/walkers.py +++ b/tatsu/walkers.py @@ -4,8 +4,8 @@ from typing import Any, Mapping from contextlib import contextmanager -from tatsu.objectmodel import Node -from tatsu.util import is_list +from .objectmodel import Node +from .util import is_list class NodeWalkerMeta(type):