Python minimal package

The optional “” for setuptools-based Python packages can be reduced to a one-line file for simple Python packages, by putting the project metadata in setup.cfg. The example setup.cfg file below is associated with a file containing merely:

from setuptools import setup; setup()

This is installed as usual like:

python -m pip install -e .

It can be most effective to put all project configuration, including Python package prerequisites in setup.cfg instead of setup.cfg is human-readable and machine-parseable without first installing the package. Putting as many parameters as possible into setup.cfg instead of is important and beneficial for reasons including:

  • reproducible results
  • security risk mitigation
  • getting package prerequisite tree list

This is an example of best practices (since 2016) of minimal using setup.cfg. It does not use requirements.txt.

setup.cfg holds the machine-readable configuration, easy for humans too. The “version” is contained in file “mypkg/” as Python code:

__version__ = "1.2.3"

setup.cfg file contains:

name = mypkg
author = Joe Smith
author_email =
description = My awesome program prints cool messages
version = attr: mypkg.__version__
url =
keywords =
  cool printing
classifiers =
  Development Status :: 4 - Beta
  Intended Audience :: Science/Research
  Programming Language :: Python :: 3
  Topic :: Scientific/Engineering
license_files =

python_requires = >= 3.8
packages = find:
zip_safe = False
install_requires =
#  numpy

tests =

console_scripts =
#  joesprog = mypkg:__main__:cli

“console_scripts” expects a file “mypkg/” with the function “cli()” designed to accept command line input, perhaps using argparse.ArgumentParser

The companion to setup.cfg is pyproject.toml. pyproject.toml is used in general for Python project settings, including ones not using setuptools. The standard way to communicate that setuptools is used for a Python project is with pyproject.toml containing:

requires = ["setuptools", "wheel"]

PEP8 checking via flake8 is configured in .flake8:

max-line-length = 132
exclude = .git,__pycache__,doc/,docs/,build/,dist/,archive/
per-file-ignores =

MyPy type hint checking is configured via .mypy.ini. is used to specify external files installed.


  • install_requires cannot read requirements.txt as file: is not in the setup.cfg install_requires input types
  • python_requires parameter avoids user confusion if they have an old Python version. Instead of them opening a GitHub issue or just not using your program at all, they’ll get a useful error message.

Classifiers are optional, but help your project be indexed better in PyPI (and hence search engines). Classifiers must be from this official classifiers list or they will fail when uploading your package to PyPI.

Python can easily import Fortran code using f2py. See this f2py example setuptools 38.6 and wheel 0.31 support Markdown README. Pip 10 brought pyproject.toml support, necessary for clean handling of Python Extension Modules via Numpy as well as setup.cfg support.

Related: Upload user Python module to PyPI