[UPD][WIP] Atualização Biblioteca, incluído o arquivo pyproject.toml #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Atualização Biblioteca para o padrão atual do Python, incluído o arquivo pyproject.toml
PR é um WIP "Trabalho em Andamento" achei melhor subir ainda em Rascunho para validar, debater e analisar junto aos outros desenvolvedores se essa atualização está sendo feita de acordo com o que o projeto busca.
Ao testar o PR #46 e rodar o comando tox localmente vi algumas mensagens de erro
Erros existentes hoje ao rodar o comando tox localmente
Erro namespace https://peps.python.org/pep-0420/
erpbrasil.base-UPD_FIX-pre_commit_libs/.tox/check/lib64/python3.9/site-packages/setuptools/dist.py:674: SetuptoolsDeprecationWarning: The namespace_packages parameter is deprecated.
!!
!!
ep.load()(self, ep.name, value)
erpbrasil.base-UPD_FIX-pre_commit_libs/.tox/check/lib64/python3.9/site-packages/isort/settings.py:500: UserWarning: W0503: Deprecated config options were used: not_skip.Please see the 5.0.0 upgrade guide: https://pycqa.github.io/isort/docs/upgrade_guides/5.0.0.html
warn(
erpbrasil.base-UPD_FIX-pre_commit_libs/.tox/check/lib64/python3.9/site-packages/isort/main.py:1276: UserWarning: W0501: The following deprecated CLI flags were used and ignored: --recursive!
warn(
erpbrasil.base-UPD_FIX-pre_commit_libs/.tox/check/lib64/python3.9/site-packages/isort/main.py:1280: UserWarning: W0500: Please see the 5.0.0 Upgrade guide: https://pycqa.github.io/isort/docs/upgrade_guides/5.0.0.html
warn(
Atualização da biblioteca
Olhando de corrigir achei melhor partir para atualizar a biblioteca, seguem algumas referencias:
PEP 518 – Specifying Minimum Build System Requirements for Python Projects
https://peps.python.org/pep-0518/
Abstract
This PEP specifies how Python software packages should specify what build dependencies they have in order to execute their chosen build system. As part of this specification, a new configuration file is introduced for software packages to use to specify their build dependencies (with the expectation that the same configuration file will be used for future configuration details).
Specification
The build system dependencies will be stored in a file named pyproject.toml that is written in the TOML format
PEP 621 – Storing project metadata in pyproject.toml
https://peps.python.org/pep-0621/
This PEP specifies how to write a project’s core metadata in a pyproject.toml file for packaging-related tools to consume.
https://snarky.ca/what-the-heck-is-pyproject-toml/
And so now projects like Black, coverage.py, towncrier, and tox (in a way) allow you to specify their configurations in pyproject.toml instead of in a separate file.
With that you get to participate in thePEP 517 world of standards! 😉 And as I said, you can now rely on a specific version of setuptools and get build isolation as well (which is why the current directory is not put on sys.path automatically; you will need sys.path.insert(0, os.path.dirname(file)) or equivalent if you're importing local files).
But there's a bonus if you use a pyproject.toml file with a setup.cfg configuration for setuptools: you don't need a setup.py file anymore! Since tools like pip are going to call setuptools using the PEP 517 API instead of setup.py it means you can delete that setup.py file (although if you use editable installs make sure you are using pip 21.3 or newer)!
Apagar ou não o arquivo setup.py?
https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
When using declarative configs via pyproject.toml with setuptools<64.0.0, users can still keep a very simple setup.py just to ensure editable installs are supported, for example:
from setuptools import setup
setup()
Versions of setuptools >=64.0.0 do not require this extra minimal setup.py file.
https://packaging.python.org/en/latest/flow/
The document aims to outline the flow involved in publishing/distributing a distribution package, usually to the Python Package Index (PyPI). It is written for package publishers, who are assumed to be the package author.
Na alteração dos arquivos usei como referencia um projeto que está sendo usado pela OCA a partir da v17
https://github.com/sbidoul/whool/tree/main
A standards-compliant Python build backend to package individual Odoo addons.
Com isso acabei incluindo algumas novas Libs que estão sendo usadas por esse projeto
Ambiente
https://pypi.org/project/hatchling/
Modern, extensible Python build backend
https://pypi.org/project/hatch-vcs/
This provides a plugin for Hatch that uses your preferred version control system (like Git) to determine project versions.
Linter
https://github.com/astral-sh/ruff
An extremely fast Python linter and code formatter, written in Rust.
Deixei comentado no arquivo tox.ini:
Ao rodar localmente o ruff já está alterando diversos arquivos, eu deixei nas opções além do --fix o --unsafe-fixes para testar e ver o que ele está fazendo, basicamente e o tratamento de string que foi simplificado, importações repetidas ( isso acredito já pode ser alterado na versão atual ), remoção da linha do enconding utf-8 ( já está depreciado junto com a versão 2.7 importante dizer que nesse PR a versão mínima do python está sendo alterada para 3.7 ) e outras pequenas alterações que deveram aparecer, deixei isso de fora desse PR para não "poluir" o PR com muitas alterações, bom como escrevi acima é apenas um rascunho para saber se tem outras pessoas vendo essa questão e debater qual o melhor caminho a seguir.
cc @rvalyi @renatonlima @marcelsavegnago @mileo