Debian Codegraph @

README.rst

raw
1 **Flit** is a simple way to put Python packages and modules on PyPI.
2 It tries to require less thought about packaging and help you avoid common
3 mistakes.
4 See `Why use Flit? <https://flit.readthedocs.io/en/latest/rationale.html>`_ for
5 more about how it compares to other Python packaging tools.
6
7 Install
8 -------
9
10 ::
11
12 $ python3 -m pip install flit
13
14 Flit requires Python 3 and therefore needs to be installed using the Python 3
15 version of pip.
16
17 Python 2 modules can be distributed using Flit, but need to be importable on
18 Python 3 without errors.
19
20 Usage
21 -----
22
23 Say you're writing a module ``foobar`` — either as a single file ``foobar.py``,
24 or as a directory — and you want to distribute it.
25
26 1. Make sure that foobar's docstring starts with a one-line summary of what
27 the module is, and that it has a ``__version__``:
28
29 .. code-block:: python
30
31 """An amazing sample package!"""
32
33 __version__ = "0.1"
34
35 2. Install flit if you don't already have it::
36
37 python3 -m pip install flit
38
39 3. Run ``flit init`` in the directory containing the module to create a
40 ``pyproject.toml`` file. It will look something like this:
41
42 .. code-block:: ini
43
44 [build-system]
45 requires = ["flit_core >=3.2,<4"]
46 build-backend = "flit_core.buildapi"
47
48 [project]
49 name = "foobar"
50 authors = [{name = "Sir Robin", email = "[email protected]"}]
51 dynamic = ["version", "description"]
52
53 [project.urls]
54 Home = "https://github.com/sirrobin/foobar"
55
56 You can edit this file to add other metadata, for example to set up
57 command line scripts. See the
58 `pyproject.toml page <https://flit.readthedocs.io/en/latest/pyproject_toml.html#scripts-section>`_
59 of the documentation.
60
61 If you have already got a ``flit.ini`` file to use with older versions of
62 Flit, convert it to ``pyproject.toml`` by running ``python3 -m flit.tomlify``.
63
64 4. Run this command to upload your code to PyPI::
65
66 flit publish
67
68 Once your package is published, people can install it using pip just like
69 any other package. In most cases, pip will download a 'wheel' package, a
70 standard format it knows how to install. If you specifically ask pip to install
71 an 'sdist' package, it will install and use Flit in a temporary environment.
72
73
74 To install a package locally for development, run::
75
76 flit install [--symlink] [--python path/to/python]
77
78 Flit packages a single importable module or package at a time, using the import
79 name as the name on PyPI. All subpackages and data files within a package are
80 included automatically.