Should I be using only pyproject.toml? [closed]
Asked Answered
Y

2

10

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.

Yea answered 10/8, 2022 at 16:54 Comment(6)
I think the only answer is "not yet". 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 uses pip, then there's no need to support poetry, for example.)Pneumonectomy
Depends on your needs. If you support only modern systems (no EOL versions) and only PEP660 enabled backends (no setuptools yet, so I doubt it is your case) - you may go with pyproject.toml only, but users won't like this. But you can keep all configuration in pyproject.toml and use one-liner as setup.py (no setup.cfg; in setup.py just import setuptools; setuptools.setup()).Ghat
Yes. As of today, I would definitely recommend the default to be pyproject.toml. If your project stumbles unto something that prevents from using pyproject.toml, then fall back to something else, but there are less and less hold-offs by the day. Even setuptools can be used with pyproject.toml only (without setup.cfg and setup.py).Hanan
related: https://mcmap.net/q/20041/-is-setup-cfg-deprecated, https://mcmap.net/q/24259/-what-is-pyproject-toml-file-forGraig
Does this answer your question? What are the downsides to relying purely on pyproject.toml?Houdini
That this perfectly reasonable question does not have a reasonable answer but is closed as being "opinion-based" says a lot about the awful mess of the Python packaging world.Newsstand
P
-1

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.

Purism answered 22/1, 2024 at 10:26 Comment(0)
L
-1

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.

Legislature answered 22/1, 2024 at 10:44 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.