textual icon indicating copy to clipboard operation
textual copied to clipboard

Update package metadata and dev experience

Open ofek opened this issue 3 years ago • 6 comments

Background

Hello there! As discussed in Discord, this is a PoC showing what a switch to Hatch would look like. Some new users include Black, Pydantic, MkDocs, and FastAPI.

The only thing lost is the lock file, since the format is not yet standardized. This can be thought of as an improvement though since Textual is a library for actual apps to use. (examples: https://github.com/ics-py/ics-py/pull/354, https://github.com/P403n1x87/austin-python/pull/9, https://github.com/delb-xml/delb-py/commit/010f5f056572712ce965c33a0a325358347d395a)

Build backend

The Python packaging ecosystem has standardized on the format for metadata declaration (PEP 621/PEP 631). The build backend hatchling (of which I am a maintainer in the PyPA) is now used as that is the default in the official Python packaging tutorial.

Hatchling is available on all the major distribution channels such as Debian, Fedora, Arch Linux, conda-forge, Nixpkgs, Alpine Linux, FreeBSD/OpenBSD, Gentoo Linux, MacPorts, OpenEmbedded, Spack, MSYS2, etc.

PyPI landing page

As you can see on https://pypi.org/project/textual/0.2.0b8/, the links to code samples and images are broken. This PR fixes that by using @hynek's awesome hatch-fancy-pypi-readme plugin.

Dev experience

The dependencies for testing, linting, and documentation are now separated into 3 different environments. This speeds up install/syncing operations and reduces the chance of conflicts or runtime side effects.

  • default - the dependencies for testing are installed here along with the project and the dev optional dependency group. the default environment is special in that Hatch will use it always in lieu of a selection e.g. hatch run test vs hatch run docs:serve
  • docs - the dependencies for documentation are installed here. the project and the dev optional dependency group are also required for mkdocstrings auto-generation of docs
  • lint - only the dependencies for linting are installed here

This now works on Windows! (Makefiles do not without great effort)

Python version cap

I removed the Python upper bound constraint as upper bounds for libraries are heavily discouraged by the community and that was just a thing that Poetry recommended.

Future

  • Move config for Mypy out of mypy.ini and into pyproject.toml
  • Hatch has a large ecosystem of plugins, so for example you could use Git for versioning or ship optional wheels compiled with Mypyc, as Black recently did
  • If you want I can do this for Rich too

ofek avatar Oct 21 '22 00:10 ofek

Thanks! Will look at this after the pending release. Need to understand a bit more about Hatch.

willmcgugan avatar Oct 22 '22 14:10 willmcgugan

Happy to help! I'm interested in hearing your thoughts.

ofek avatar Oct 22 '22 14:10 ofek

I rebased, would you mind triggering the CI with that button below?

ofek avatar Oct 31 '22 14:10 ofek

Passing 🙂

ofek avatar Oct 31 '22 15:10 ofek

Thanks @ofek . We're just about to release a new version. But I reckon we should go all in with Hatch after that.

willmcgugan avatar Oct 31 '22 15:10 willmcgugan

Cool, rebased again

ofek avatar Nov 01 '22 16:11 ofek

Thanks. Next release will be "hatched"!

willmcgugan avatar Nov 07 '22 12:11 willmcgugan