Upgrade packaging to pyproject.toml and hatchling

In order to upgrade the packaging of Tryton, I created a hatchling plugin to set dynamic requirements based on the tryton.cfg file: Tryton / hatch-tryton · GitLab
I also started a merge request to upgrade all the packages: Draft: Upgrade to pyproject using hatchling as build-system (!3137) · Merge requests · Tryton / Tryton · GitLab

For now I have identify only one drawback compare to the former setuptools. It is the editable installation. With hatchling it can only use editable with some type of path rewrite which does not contain the rewrite needed for standard module.
But I do not think it is a big deal because non-standard module could be installed in a different path (than trytond.modules) and register the proper entrypoint to be loaded from their python module name.

Also for tryton and trytond, we had custom command to compile mo and rng files. I solved it by using a hatch_build.py custom hook which compile the files on building. The hook file can also be run as python script to compile the same files.

There are still some work to do to upgrade the cx_Freeze build to use the cxfreeze command and pyproject.toml

1 Like

The cookiecutter template has been updated and show how editable mode could work.

Another change due the removal of the editable installation, is that tox must no more run test using develop mode. This means that the tests are run from the virtual environment installation. The benefit is that it also tests that every needed files are correctly installed. So I changed also for the non-modules packages even if they could be installed in editable mode.
I needed a little trick which is to add changedir = {toxworkdir} in order to prevent unittest to import the files form the repository (there are some code that change the sys.path in unittest).

Indeed as we need to calculate the files to include dynamically (depends on sys.prefix, compile with g-ir-compiler etc.), I kept the setup-freeze.py which do not depend on setuptools directly but only through cx_Freeze.

The MR is ready for testing.
And by the way, I took the opportunity to remove support of Python 3.9 and add Python 3.14 to reduce the load on the CI runners.

I have made releases of Tryton’s libraries which have been upgraded to pyproject.toml and hatch-tryton.
But there is a problem with the rendering of Author on https://pypi.porg/ as you can see on python-sql · PyPI. The metadata form pyproject.toml are correct according to pyproject.toml specification - Python Packaging User Guide but the problem is interpretation of the Author and Author-email of PyPi’s warehouse: Odd rendering of author when using PEP 621 metadata. · Issue #9400 · pypi/warehouse · GitHub

I do not know exactly what to do. There are few options:

  • wait for warehouse to be fixed (and support multiple emails)
  • remove emails from the project.authors (and we will loose the verified details once warehouse is fixed)
  • include only authors with emails in project.authors

In the PKG-Info of hatch-tryton you mention MIT as license, but LICENSE file does not contain respective license information. Maybe add it in the next release? Thanks!

The license is there: LICENSE · branch/default · Tryton / hatch-tryton · GitLab and it is included in archive and the wheel.

A general problem with the released tarballs is like exemplary filed for https://foss.heptapod.net/tryton/coda/-/issues/16.

Should I file individual issues for all affected projects or is it sufficient like this?

Please no, it is not a bug but a feature.