Python packaging recently got awesome!
pyproject.toml is the standard place to configure everything,
defined in PEP 518.
Because lack of pyproject.toml support in some tools
is the only part about Python packaging that isn’t awesome already,
each tool has a little ✅ or ❌ to indicate support.
Make sure your program behaves as you intended in different environments.
-
tox ✅ (pyproject.toml, setup.cfg, tox.ini)
Use this to define environments in which to test your package. Like continuous integration on your local machine. Can be integrated into CI like GH Actions, AppVeyor or Travis.
-
pytest ❌ (setup.cfg, tox.ini, pytest.ini)
Unofficial standard for Python testing. Many Plugins, user-friendly error reporting using just
assert. Good defaults make lack ofpyproject.tomlsupport painless. -
Static type checking. It tests if the values you pass to and return from functions match the type annotations.
-
Coverage.py ✅ (pyproject.toml, .coveragerc)
Code coverage measurement for Python.
Make sure feedback in PRs isn’t mostly about code style, but about actual content.
-
pylint ✅ (pyproject.toml, setup.cfg, pylintrc, .pylintrc) – upcoming in v2.5,
flake8 ❌ (setup.cfg, tox.ini, .flake8)Generic style checkers for many possible code smells.
-
pycodestyle ❌ (setup.cfg, tox.ini)
A style checker focused on PEP 8 compliance. Is included in
flake8. -
A optionless code formatter that frees your mind from having to think about style.
-
isort ✅ (pyproject.toml, setup.cfg, tox.ini, .isort.cfg)
A formatter for reordering imports. Many options!
Manage your package’s dependencies, and publish it to the PyPI.
With poetry and flit, there’s two easy to use command line applications.
No pip, twine, and ./setup.py juggling!
-
A tool for application and library development that manages dependencies. Keeps an unchanging project environment via lockfile and other than pip has an actual dependency solver.
-
flit ✅ (pyproject.toml, flit.ini)
A tool for simple packages without compilation step. Use e.g. get_version if you think your git tags are good as a source of versioning.
-
If you’re still stuck in
setup.pyworld, this might soothe your pain. It allows you to upload awheelto PyPI with little hassle. It has no configuration. -
setuptools_scm ✅ (pyproject.toml, setup.cfg)
A package that allows you to have one true source of versions: Your SCM metadata (e.g.
git tag). Installing a “dirty” untagged version will automatically give you a version string that comparse as newer than the last clean one. It can work at build time as a command line tool/Python API or as a runtime library.
These don’t need to be configured per project with pyproject.toml,
but need to read its [build-system] section to install the project!
-
pip ✅ (pyproject.toml, setup.py)
Python’s classic package manager. Widespread like no other and therefore very robust. Except for actually resolving dependencies, which it does rather duct-tape-and-hope like.
-
poetry(and to a small degreeflit) is a package manager itself. -
pipenv ❌ (Pipfile)
pipenvis not a package creation tool, it’s an application creation tool. If you want to build a library, choosepoetryorflit.
-
A dependency management tool that converts between and allows reasoning about all above.