Skip to content

Commit

Permalink
[UPD] Atualização Biblioteca para o padrão atual do Python, incluído …
Browse files Browse the repository at this point in the history
…o arquivo pyproject.toml
  • Loading branch information
mbcosta committed Feb 9, 2024
1 parent 8c3e4dd commit 41b94a6
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 176 deletions.
17 changes: 13 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
111 changes: 111 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"}
]
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
90 changes: 1 addition & 89 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
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()
8 changes: 2 additions & 6 deletions src/erpbrasil/__init__.py
Original file line number Diff line number Diff line change
@@ -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__)
133 changes: 56 additions & 77 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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/*

0 comments on commit 41b94a6

Please sign in to comment.