Flit is a simple way to put Python packages and modules on PyPI.
$ python3 -m pip install flit
Flit requires Python 3 and therefore needs to be installed using the Python 3 version of pip.
Python 2 modules can be distributed using Flit, but need to be importable on Python 3 without errors.
Say you’re writing a module
foobar — either as a single file
or as a directory — and you want to distribute it.
Make sure that foobar’s docstring starts with a one-line summary of what the module is, and that it has a
"""An amazing sample package!""" __version__ = '0.1'
Create a file
flit.ininext to the module. It should look like this:
[metadata] module=foobar author=Sir Robin email@example.com home-page=https://github.com/sirrobin/foobar # If you want command line scripts, this is how to declare them. # If not, you can leave this section out completely. [scripts] # foobar:main means the script will do: from foobar import main; main() foobar=foobar:main
You can use
flit initto easily create a basic
flit.inifile for your package.
Besides the details shown above, there are other fields you can add—see the flit.ini page of the docs.
Install flit if you don’t already have it:
python3 -m pip install flit
Run this command to upload your code to PyPI:
To install a package locally for development, run:
flit install [--symlink] [--python path/to/python]
Flit packages a single importable module or package at a time, using the import name as the name on PyPI. All subpackages and data files within a package are included automatically.
See Flit’s documentation for more information.
- The flit.ini config file
- Specifying entry points
- Controlling package uploads
- Reproducible builds
- Release history
New in version 0.10.
Setting this to any non-empty value will stop flit from making network connections (unless you explicitly ask to upload a package). This is intended for downstream packagers, so if you use this, it’s up to you to ensure any necessary dependencies are installed.
flit installwill fail when run as root on POSIX systems, because installing Python modules systemwide is not recommended. Setting this to any non-empty value allows installation as root. It has no effect on Windows.