Should I be using only pyproject.toml or use it with setup.py and setup.cfg? Or perhaps some other combination of them.
I can't find any definitive answer to this question so I'd be pleased if someone could enlighten the matter.
Should I be using only pyproject.toml or use it with setup.py and setup.cfg? Or perhaps some other combination of them.
I can't find any definitive answer to this question so I'd be pleased if someone could enlighten the matter.
I recently published a Python library to PyPI and I only used the pyproject.toml file to build and distribute the package (I did not have a need for setup.py or setup.cfg).
If that is your use-case (publishing the package) then pyproject.toml is sufficient. I hope this information helps.
pyproject.toml is sufficient for most projects. It's introduced in PEP 518. However, a complicated project would probably require a setup.py or a MANIFEST.in if needed. Check the Python packaging guide: https://packaging.python.org/en/latest/overview/
You can check out more info about setuptools and setup.py in here: https://packaging.python.org/en/latest/discussions/setup-py-deprecated/#setup-py-deprecated
This question also provides additional information: What is pyproject.toml file for?
Generally, pyproject.toml is needed if you want to publish a project. It includes basic settings, configurations, dependencies, links, and info about your project. setup.py is not mandatory, but can be used to configure your project. A fact worth noting is that although setuptools and setup.py is not deprecated, commands like python setup.py install
have been replaced by python -m pip install
.
© 2022 - 2025 — McMap. All rights reserved.
pyproject.toml
is intended to be a tool-agnostic file, but not all tools support it, and I don't think most code bases need to be tool-agnostic. (If you or your organization always usespip
, then there's no need to supportpoetry
, for example.) – Pneumonectomypyproject.toml
and use one-liner as setup.py (no setup.cfg; in setup.py justimport setuptools; setuptools.setup()
). – Ghatpyproject.toml
. If your project stumbles unto something that prevents from usingpyproject.toml
, then fall back to something else, but there are less and less hold-offs by the day. Even setuptools can be used withpyproject.toml
only (withoutsetup.cfg
andsetup.py
). – Hanan