Python: replace with pyproject.toml

Related: Minimal

pip ≥ 9.1 can use pyproject.toml instead of, for simpler syntax.

flit uses pyproject.toml for simpler PyPi uploads, and can also install programs (as alternative to pip). End users can simply flit installfrom Github, without needing to git clone or use PyPi (unless they want to). flit and pyproject.toml lower Python program distribution difficulty for developers who don’t want to mess with PyPi, but also make it easier for those who do use PyPi.


  1. author: flit publish to PyPi
  2. end-user: python -m pip install yourprogram this uses pyproject.toml alone to install.

Users can also install from local or remote Git repos:

  • end-user: flit installfrom this downloads and installs the latest Git commit to master branch (or other branch or release version they choose)
  • developer-user: git clone your repo and install in develop mode by flit install -s. This puts a symbolic link to your local Git directory (where you git clone‘d).

This standard was defined in PEP 517 and PEP 518

Minimal pyproject.toml

  1. assuming your package is named myprogram, have a directory structure like
  2. ensure your starts with a one-line description and version. You must increment this version for each PyPi upload (or use bumpversion).
    """My program is 2x faster and 1/3 the size of Hello World."""
    __version__ = '0.1.0'
  3. pyproject.toml contains something like:
    requires = ["flit"]
    build-backend = "flit.buildapi"
    module = "myprogram"
    author = "Author Name"
    author-email = "[email protected]"
    home-page = ""
    requires=['numpy','matplotlib (>=2.1)']
    'Development Status :: 4 - Beta',
    'Programming Language :: Python']

PyPi upload

  1. Sign up for PyPi account. It may take several hours to get the confirmation email.
  2. create ~/.pypirc with the content
    index-servers =
    username=<your pypi username>

    Note that I did NOT save my password for security.

  3. In your Python package directory that you want to upload
    flit upload

Now your package is live to the world on PyPi. Anyone can install it via

python -m pip install myprogram


  • Obtain flit via
    python -m pip install flit
  • description-file must be .rst or .md format.
  • These old methods are superceded by the methods above.
    • python install python -m pip install .flit install
    • python develop python -m pip install -e .flit install -s
    • python sdist bdist_wheel uploadflit upload
  • flit reference
  • To my knowledge, f2py still needs, numpy.distutils and python -m pip install -e .

Leave a Comment