| 1 |
Why use Flit? |
| 2 |
============= |
| 3 |
|
| 4 |
*Make the easy things easy and the hard things possible* is an old motto from |
| 5 |
the Perl community. Flit is entirely focused on the *easy things* part of that, |
| 6 |
and leaves the hard things up to other tools. |
| 7 |
|
| 8 |
Specifically, the easy things are pure Python packages with no build steps |
| 9 |
(neither compiling C code, nor bundling Javascript, etc.). The vast majority of |
| 10 |
packages on PyPI are like this: plain Python code, with maybe some static data |
| 11 |
files like icons included. |
| 12 |
|
| 13 |
It's easy to underestimate the challenges involved in distributing and |
| 14 |
installing code, because it seems like you just need to copy some files into |
| 15 |
the right place. There's a whole lot of metadata and tooling that has to work |
| 16 |
together around that fundamental step. But with the right tooling, a developer |
| 17 |
who wants to release their code doesn't need to know about most of that. |
| 18 |
|
| 19 |
What, specifically, does Flit make easy? |
| 20 |
|
| 21 |
- ``flit init`` helps you set up the information Flit needs about your |
| 22 |
package. |
| 23 |
- Import packages in subfolders are automatically included: specify only the |
| 24 |
top-level import package (for example, ``django``), and Flit includes |
| 25 |
subpackages such as ``django.db`` and ``django.db.models.sql``. |
| 26 |
- Data files within a package directory are automatically included. |
| 27 |
Missing data files has been a common packaging mistake with other tools. |
| 28 |
- The version number is taken from your package's ``__version__`` attribute, |
| 29 |
so that always matches the version that tools like pip see. |
| 30 |
- ``flit publish`` uploads a package to PyPI, so you don't need a separate tool |
| 31 |
to do this. |
| 32 |
|
| 33 |
Setuptools, the most common tool for Python packaging, now has shortcuts for |
| 34 |
many of the same things. But it has to stay compatible with projects published |
| 35 |
many years ago, which limits what it can do by default. |
| 36 |
|
| 37 |
Flit also has some support for :doc:`reproducible builds <reproducible>`, |
| 38 |
a feature which some people care about. |
| 39 |
|
| 40 |
There have been many other efforts to improve the user experience of Python |
| 41 |
packaging, such as `pbr <https://pypi.org/project/pbr/>`_, but before Flit, |
| 42 |
these tended to build on setuptools and distutils. That was a pragmatic |
| 43 |
decision, but it's hard to build something radically different on top of those |
| 44 |
libraries. The existence of Flit spurred the development of new standards, |
| 45 |
like :pep:`518` and :pep:`517`, which are now used by other packaging tools |
| 46 |
such as `Poetry <https://python-poetry.org/>`_ and |
| 47 |
`Enscons <https://pypi.org/project/enscons/>`_. |
| 48 |
|
| 49 |
Other options |
| 50 |
------------- |
| 51 |
|
| 52 |
If your package needs a build step, you won't be able to use Flit. |
| 53 |
`Setuptools <https://setuptools.readthedocs.io/en/latest/>`_ is the de-facto |
| 54 |
standard, but newer tools such as Enscons_ also cover this case. |
| 55 |
|
| 56 |
Flit also doesn't help you manage dependencies: you have to add them to |
| 57 |
``pyproject.toml`` by hand. Tools like Poetry_ and `Pipenv |
| 58 |
<https://pypi.org/project/pipenv/>`_ have features which help add and update |
| 59 |
dependencies on other packages. |