From 41b94a6983bbfda1c320a0459a7179e456fc5d66 Mon Sep 17 00:00:00 2001 From: Magno Costa Date: Fri, 9 Feb 2024 16:29:19 -0300 Subject: [PATCH] =?UTF-8?q?[UPD]=20Atualiza=C3=A7=C3=A3o=20Biblioteca=20pa?= =?UTF-8?q?ra=20o=20padr=C3=A3o=20atual=20do=20Python,=20inclu=C3=ADdo=20o?= =?UTF-8?q?=20arquivo=20pyproject.toml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 17 +++-- pyproject.toml | 111 +++++++++++++++++++++++++++++++ setup.py | 90 +------------------------- src/erpbrasil/__init__.py | 8 +-- tox.ini | 133 ++++++++++++++++---------------------- 5 files changed, 183 insertions(+), 176 deletions(-) create mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5bca29b..3c85625 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,20 +5,29 @@ exclude: '^(\.tox|ci/templates|\.bumpversion\.cfg)(/|$)' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: debug-statements - repo: https://github.com/timothycrosley/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.12.1 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 6.0.0 + rev: 7.0.0 hooks: - id: flake8 + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.1.14 + hooks: + # Run the linter. + - id: ruff + args: [ --fix, --unsafe-fixes ] + # Run the formatter. + - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d20cc0f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,111 @@ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "erpbrasil.base" +description = "erpbrasil.base - Biblioteca python para auxiliar em operações corriqueiras dos ERPs Python Brasileiros." +readme = "README.rst" +authors = [ + {name = "Luis Felipe Mileo", email = "mileo@kmee.com.br"} +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License", +] +requires-python = ">=3.7" +dependencies = [ + "manifestoo-core>=1.1", + "wheel", + "tomli; python_version<'3.11'", + "importlib_metadata; python_version<'3.8'", +] +scripts = {"erpbrasil.base" = "erpbrasil.base.cli:main"} +dynamic = ["version"] + +[tool.hatch.build.targets.wheel] +packages = ["src/erpbrasil"] + +#[tool.hatch.build.target.sdist.force-include] +#"src/cli.py" = "src/project_name/cli.py" + +#[project.scripts] +#executive = "erpbrasil.base.cli:main" + +[project.optional-dependencies] +test = [ + "pytest", + "coverage[toml]", + "mypy", +] +doc = [ + "sphinx", + "furo", + "myst-parser", + "towncrier", + "sphinxcontrib-towncrier", +] + +[project.urls] +Homepage = "https://github.com/erpbrasil/erpbrasil.base" +Documentation = "https://erpbrasilbase.readthedocs.io/" +Changelog = "https://erpbrasilbase.readthedocs.io/en/latest/changelog.html" +Source = "https://github.com/erpbrasil/erpbrasil.base" + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build] +exclude = [ + "/.github", +] + +# mypy + +[tool.mypy] +strict = true +show_error_codes = true + +# coverage + +[tool.coverage.run] +branch = true +source_pkgs = ["erpbrasil.base"] + +[tool.coverage.paths] +source = ["src", ".tox/*/site-packages"] + +[tool.coverage.report] +show_missing = true +exclude_lines = [ + "pragma: no cover", +] + +# towncrier + +[tool.towncrier] +name = "erpbrasil.base" +directory = "news" +filename = "CHANGELOG.md" +title_format = "## [{version}](https://github.com/erpbrasil/erpbrasil.base/tree/{version}) - {project_date}" +issue_format = "[#{issue}](https://github.com/erpbrasil/erpbrasil.base/issues/{issue})" +underlines = ["", "", ""] + +# ruff + +[tool.ruff] +fix = true +select = [ + "E", "F", "W", "C90", "B", "I", "UP", "RUF", "TCH" +] +target-version = "py37" + +[tool.ruff.per-file-ignores] +"__main__.py" = ["B008"] + +[tool.ruff.mccabe] +max-complexity = 13 + +[tool.ruff.isort] +known-first-party = ["erpbrasil.base"] +combine-as-imports = true diff --git a/setup.py b/setup.py index 8f5915d..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,91 +1,3 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- -from __future__ import absolute_import -from __future__ import print_function - -import io -import re -from glob import glob -from os.path import basename -from os.path import dirname -from os.path import join -from os.path import splitext - -from setuptools import find_packages from setuptools import setup - -def read(*names, **kwargs): - with io.open( - join(dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8") - ) as fh: - return fh.read() - - -setup( - name="erpbrasil.base", - version="2.3.0", - license="MIT license", - description="Base", - long_description="%s\n%s" - % ( - re.compile("^.. start-badges.*^.. end-badges", re.M | re.S).sub( - "", read("README.rst") - ), - re.sub(":[a-z]+:`~?(.*?)`", r"``\1``", read("CHANGELOG.rst")), - ), - author="Luis Felipe Mileo", - author_email="mileo@kmee.com.br", - url="https://github.com/erpbrasil/erpbrasil.base", - packages=find_packages("src"), - package_dir={"": "src"}, - py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")], - namespace_packages=["erpbrasil"], - include_package_data=True, - zip_safe=False, - classifiers=[ - # complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: Unix", - "Operating System :: POSIX", - "Operating System :: Microsoft :: Windows", - "Programming Language :: Python", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - # uncomment if you test on these interpreters: - # 'Programming Language :: Python :: Implementation :: IronPython', - # 'Programming Language :: Python :: Implementation :: Jython', - # 'Programming Language :: Python :: Implementation :: Stackless', - "Topic :: Utilities", - ], - project_urls={ - "Documentation": "https://erpbrasilbase.readthedocs.io/", - "Changelog": "https://erpbrasilbase.readthedocs.io/en/latest/changelog.html", - "Issue Tracker": "https://github.com/erpbrasil/erpbrasil.base/issues", - }, - keywords=[ - # eg: 'keyword1', 'keyword2', 'keyword3', - ], - python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", - install_requires=[ - # eg: 'aspectlib==1.1.1', 'six>=1.7', - ], - extras_require={ - # eg: - # 'rst': ['docutils>=0.11'], - # ':python_version=="2.6"': ['argparse'], - }, - entry_points={ - "console_scripts": [ - "erpbrasil.base = erpbrasil.base.cli:main", - ] - }, -) +setup() diff --git a/src/erpbrasil/__init__.py b/src/erpbrasil/__init__.py index 839c9d8..d02342b 100644 --- a/src/erpbrasil/__init__.py +++ b/src/erpbrasil/__init__.py @@ -1,8 +1,4 @@ -# -*- encoding: utf-8 -*- # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages -try: - __import__("pkg_resources").declare_namespace(__name__) -except ImportError: - from pkgutil import extend_path +from pkgutil import extend_path - __path__ = extend_path(__path__, __name__) +__path__ = extend_path(__path__, __name__) diff --git a/tox.ini b/tox.ini index 13104c3..4f26391 100644 --- a/tox.ini +++ b/tox.ini @@ -1,92 +1,71 @@ ; a generative tox configuration, see: https://tox.readthedocs.io/en/latest/config.html#generative-envlist +[gh-actions] +python = + 3.7: py37 + 3.8: py38, typing + 3.9: py39, typing + 3.10: py310, typing + 3.11: py311, typing + 3.12: py312, typing, pypi-description + pypy3: pypy3 + [tox] +isolated_build = True envlist = - clean, - check, - docs, - {py34,py35,py36,py37,py38,pypy,pypy3}, + clean + check + py37 + py38 + py39 + py310 + py311 + py312 + pypy3 + lint + typing + docs + pypi-description report [testenv] -basepython = - pypy: {env:TOXPYTHON:pypy} - pypy3: {env:TOXPYTHON:pypy3} - py34: {env:TOXPYTHON:python3.4} - py35: {env:TOXPYTHON:python3.5} - {py36,docs,spell}: {env:TOXPYTHON:python3.6} - py37: {env:TOXPYTHON:python3.7} - py38: {env:TOXPYTHON:python3.8} - {bootstrap,clean,check,report,codecov}: {env:TOXPYTHON:python3} -setenv = - PYTHONPATH={toxinidir}/tests - PYTHONUNBUFFERED=yes -passenv = - * -usedevelop = false -deps = - pytest - pytest-cov +skip_missing_interpreters = True +extras = + test commands = - {posargs:pytest --cov --cov-report=term-missing -vv tests} + coverage run -m pytest {posargs} + coverage xml + coverage html -[testenv:bootstrap] -deps = - jinja2 - matrix +[testenv:lint] +basepython = python3.9 skip_install = true -commands = - python ci/bootstrap.py - -[testenv:check] deps = - docutils - check-manifest - flake8 - readme-renderer - pygments - isort -skip_install = true + pre-commit +passenv = HOMEPATH # needed on Windows commands = - python setup.py check --strict --metadata --restructuredtext - check-manifest {toxinidir} - flake8 src tests setup.py - isort --verbose --check-only --diff --recursive src tests setup.py + pre-commit run --all-files -[testenv:spell] -setenv = - SPELLCHECK=1 -commands = - sphinx-build -b spelling docs dist/docs -skip_install = true -deps = - -r{toxinidir}/docs/requirements.txt - sphinxcontrib-spelling - pyenchant +# TODO: Muitos erros, mas é necessário avaliar o que realmente deveria ser corrigido ou configurado para ser ignorado +#[testenv:typing] +#deps = mypy>=0.800 +#commands = +# mypy --strict src/erpbrasil tests -[testenv:docs] -deps = - -r{toxinidir}/docs/requirements.txt -commands = - sphinx-build {posargs:-E} -b html docs dist/docs - sphinx-build -b linkcheck docs dist/docs - -[testenv:codecov] -deps = - codecov -skip_install = true -commands = - coverage xml --ignore-errors - codecov [] +# TODO: Erro +# make: *** Nenhum alvo indicado e nenhum arquivo make encontrado. Pare. +#[testenv:docs] +#basepython = python3.9 +#extras = doc +#commands = +# make -C docs html +#allowlist_externals = make -[testenv:report] -deps = coverage -skip_install = true -commands = - coverage report - coverage html - -[testenv:clean] -commands = coverage erase -skip_install = true -deps = coverage +#[testenv:pypi-description] +#basepython = python3.10 +#skip_install = true +#deps = +# twine +#commands = +# pip wheel -w {envtmpdir}/build --no-deps . +# twine check {envtmpdir}/build/*