Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move from setuptools to hatch #1258

Merged
merged 2 commits into from Dec 12, 2023
Merged

Conversation

azmeuk
Copy link
Contributor

@azmeuk azmeuk commented Nov 11, 2023

With this PR:

  • packages are built with hatch instead of setuptools. You can check the content of the packages by running hatch build
    • pytest is still functional in the development environment
    • tox automatically builds packages, installs them and runs unit tests in a dedicated environment. So, packages are at least valid with unit tests.
  • publication is still done with zest.releaser. I am not sure how to test this without actually attempting a release. Any ideas?
  • translations catalogs are compiled:
    • at package build time (with hatch_build.py)
    • before unit tests are ran (with the babel_catalogs automatic fixture)
    • before make serve (with a Makefile target dependency)
  • thus there is no need to keep catalogs versioned in git anymore, so I removed them from the repository

If zest.releaser is actually not compatible with hatch, we could drop zest.releaser and use hatch for pypi package publication.

fixes #1238

@azmeuk azmeuk marked this pull request as draft November 11, 2023 12:17
@almet
Copy link
Member

almet commented Nov 11, 2023

Thanks for this :-)

publication is still done with zest.releaser. I am not sure how to test this without actually attempting a release. Any ideas?

You probably can try releasing on test PyPI

If zest.releaser is actually not compatible with hatch, we could drop zest.releaser and use hatch for pypi package publication.

Whatever works, I think. I don't think I'm using zest releaser myself anyway.

Makefile Show resolved Hide resolved
docs/contributing.md Show resolved Hide resolved
hatch_build.py Outdated Show resolved Hide resolved
ihatemoney/tests/conftest.py Outdated Show resolved Hide resolved
ihatemoney/tests/conftest.py Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
MANIFEST.in Outdated
@@ -1,3 +0,0 @@
include *.rst
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MANIFEST.in was used for setuptools, it is not needed anymore with hatch

@azmeuk azmeuk force-pushed the issue-1238-catalogs branch 2 times, most recently from 5cea431 to 9036f39 Compare November 18, 2023 12:45
pyproject.toml Outdated
packages = ["ihatemoney"]
[tool.hatch.build.hooks.custom]
dependencies = [
"Babel>=2.10.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the oldest babel python I could find that would support all the python versions supported by ihatemoney.
python 3.10 support has been brought with babel 2.10, using babel<2.10 would have broke minversions tests for python 3.10+

@azmeuk azmeuk force-pushed the issue-1238-catalogs branch 7 times, most recently from ea08717 to 07fa938 Compare November 18, 2023 13:16
@@ -14,9 +14,7 @@ CONTRIBUTORS
docker-compose.*
Dockerfile
docs
LICENSE
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LICENSE and README.md needs to be included in the Docker image, because hatch needs those files to build the package.

@azmeuk azmeuk marked this pull request as ready for review November 18, 2023 13:20
@azmeuk
Copy link
Contributor Author

azmeuk commented Nov 18, 2023

I think this should be mostly OK now.

You probably can try releasing on test PyPI

I could upload to testpypi with hatch publish --repo https://test.pypi.org/legacy/ --user __token__ but that means I just tested ... hatch upload.
I would have liked to test if zest.releaser functioned with that hatch configuration, but fullreleaser does not seem to have options to select another package repository.

Anyway, I could test installation with pip install --extra-index-url https://test.pypi.org/simple/ "ihatemoney==6.1.2dev" and then execute tests from the documentation, and everything works.

BTW I created the ihatemoney package on testpypi as it did not existed. I could not find your account on testpypi so I could not invite you to share ownership, but if you want just ping me.

/cc @zorun

hatch_build.py Outdated Show resolved Hide resolved
@almet
Copy link
Member

almet commented Dec 7, 2023

I've updated the python babel version to be compatible with python 3.12. See python-babel/babel#1033

@almet
Copy link
Member

almet commented Dec 7, 2023

@zorun, are you happy with this?

@zorun
Copy link
Collaborator

zorun commented Dec 11, 2023

No strong opinion on hatch itself, I don't know much about it, I just hope it's a long-term project.

Just a small thing to consider (sorry if this has been addressed), why do you specify a dependency on Babel here instead of in pyproject.toml? If it's something specific and you really need it, please add a comment.

About making releases, we should definitely have a robust, reproducible and unique way to do them. Currently we are using zest (through make release, I hope you do use that @almet ^^). But we could also do releases through the CI, executed only on tags. It would be easier, and more consistent with the Docker release. One downside is that we would have to add a pypi token as a secret on Github. By the way, Zest does not do much, it just updates the version in setup.cfg and adds a date in the changelog.

What do you think? If you are confident about that, I'm OK to see it merged after the Babel comment is addressed, and let's discuss/change the release process as a second step.

@azmeuk
Copy link
Contributor Author

azmeuk commented Dec 12, 2023

No strong opinion on hatch itself, I don't know much about it, I just hope it's a long-term project.

Indeed, there is always a risk. What reassures me is that hatch seems active, and it looks OK in comparison with the concurrence:

a14f790d49ced591

(Source: https://framapiaf.org/@fcodvpt/111533565837454708)

Just a small thing to consider (sorry if this has been addressed), why do you specify a dependency on Babel here instead of in pyproject.toml? If it's something specific and you really need it, please add a comment.

There is an explicit dependency to Babel at build time, because it is needed to dynamically compile translations catalogs and put them into the package. I added a comment.

@zorun
Copy link
Collaborator

zorun commented Dec 12, 2023

Ok, thanks, it looks good then!

I just merged some translation updates, can you rebase one last time? Then I will disable .mo generation on weblate.

azmeuk and others added 2 commits December 12, 2023 13:26
packages are built with hatch instead of setuptools.
Translations catalogs are compiled at package build time, and before unit tests are
ran. Thus there is no need to keep them versioned in git anymore.
@almet
Copy link
Member

almet commented Dec 12, 2023

Thanks!

@zorun I'm myself still doing manual releases, but having these automated seems a good goal 👍

@almet almet merged commit edefb51 into spiral-project:master Dec 12, 2023
17 checks passed
@azmeuk azmeuk deleted the issue-1238-catalogs branch December 12, 2023 13:22
@zorun
Copy link
Collaborator

zorun commented Dec 14, 2023

It looks like something is failing with Python 3.12: https://github.com/spiral-project/ihatemoney/actions/runs/7203079881/job/19622368172

@zorun
Copy link
Collaborator

zorun commented Dec 14, 2023

@azmeuk also, can you add me to the package on test.pypi.org?

@almet
Copy link
Member

almet commented Dec 14, 2023

Tests were passing on this branch. The reported 3.12 error seems related to babel < 2.13.1 (distutils requirement fixed in https://github.com/python-babel/babel/releases/tag/v2.13.1)

@azmeuk
Copy link
Contributor Author

azmeuk commented Dec 14, 2023

@azmeuk also, can you add me to the package on test.pypi.org?

I sent you an invitation. @almet do you have an account?

@almet
Copy link
Member

almet commented Dec 14, 2023

I'm almet there :-)

@azmeuk
Copy link
Contributor Author

azmeuk commented Dec 14, 2023

You are invited too!

TomRoussel pushed a commit to TomRoussel/ihatemoney that referenced this pull request Mar 2, 2024
Co-authored-by: Alexis Métaireau <alexis@notmyidea.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not version the compiled catalogs
3 participants