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

Update package metadata and dev experience #971

Merged
merged 2 commits into from
Nov 7, 2022

Conversation

ofek
Copy link
Contributor

@ofek ofek commented Oct 21, 2022

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: ics-py/ics-py#354, P403n1x87/austin-python#9, delb-xml/delb-py@010f5f0)

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

@willmcgugan
Copy link
Collaborator

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

@ofek
Copy link
Contributor Author

ofek commented Oct 22, 2022

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

@ofek ofek changed the base branch from css to main October 22, 2022 20:28
@ofek ofek force-pushed the modernize-metadata branch 3 times, most recently from 215d134 to 9f272ba Compare October 22, 2022 21:42
hatch.toml Outdated Show resolved Hide resolved
hatch.toml Outdated Show resolved Hide resolved
@ofek
Copy link
Contributor Author

ofek commented Oct 31, 2022

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

@ofek
Copy link
Contributor Author

ofek commented Oct 31, 2022

Passing 🙂

@willmcgugan
Copy link
Collaborator

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

@ofek
Copy link
Contributor Author

ofek commented Nov 1, 2022

Cool, rebased again

@willmcgugan willmcgugan merged commit 4034d95 into Textualize:main Nov 7, 2022
@willmcgugan
Copy link
Collaborator

Thanks. Next release will be "hatched"!

@ofek ofek deleted the modernize-metadata branch November 7, 2022 13:57
@ofek ofek mentioned this pull request Nov 24, 2022
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.

2 participants