pypa/flit

Is Hatch officially recommended by PyPA over Flit?

deepyaman opened this issue ยท 3 comments

I could have also asked this in pypa/hatch, but given my question stems from an opinionated PR by the maintainer of Hatch, I thought this would get more new information.

I've used Flit on several projects previously, after I first saw it used in https://github.com/tiangolo/typer. Earlier today, I was poking around in https://tiangolo/fastapi, when I noticed that they had migrated to Hatch, and then I saw the changes in tiangolo/fastapi#5240. This PR is worded in a way that makes it seem like PyPA's official recommendation is to use Hatch, and that it provides a lot of advantages over Flit.

  1. Is that true?
  2. Are there similar reasons to prefer Flit to Hatch? Is one or the other right in certain situations, or is it just personal preference?

I think that FastAPI PR gives a slightly misleading impression. Flit supports the same standards as Hatch, it would have been totally possible to update the metadata to use the [project] table (specification) and to tell contributors to install things with pip, without changing backend. They could also have kept Python 3.6 support if they wanted. ๐Ÿ˜‰ Understandably, though, @ofek included a switch to the newer tool as part of modernisation.

PyPA doesn't recommend any specific tool, as far as I'm aware. At some point I asked that Flit not be presented as the default in the packaging tutorial, because I don't want people to think it's 'the officially recommended tool'. PyPA once appeared to recommend pipenv, and then a lot of people got upset with pipenv.

Certainly Hatch (and Poetry, and PDM) can do more for you than Flit. In particular, all of those tools include functionality to manage an environment associated with your project; Flit leaves that up to you to manage separately.

Is there any remaining reason to use Flit? Perhaps not. ๐Ÿ™‚ My best argument would be that for a certain type of simple packaging, Flit is a very simple, boring implementation, with no extra pieces. E.g. if you already manage development environments with virtualenv or conda and want to keep doing that, Flit will never try to create & manage a new environment for you. That's probably a fairly niche requirement, though. ๐Ÿคท

ofek commented

Hello!

PyPA's official recommendation is to use Hatch

Is that true?

No, just chosen ahead of others as the default.

it provides a lot of advantages over Flit

Is that true?

Yes, most notably plugins. This is by design as Flit wants to be minimal.

Are there similar reasons to prefer Flit to Hatch?

For libraries fundamental to the packaging ecosystem like packaging that require a build backend with vendored, or zero, dependencies.

@takluyver @ofek Thank you both for chiming in; much appreciated!