Do I need a setup.cfg if I have a setup.py?

Viewed 1220

I use setuptools to build my python package. I was using just a setup.py file, but I added a pyproject.toml in accordance with this tutorial, which appears to have been recently updated to include that file.

What I can't tell from that tutorial or this one, is whether I need to have a setup.cfg if I'm still using setup.py, and if so, what should be in it. It does show a file tree with both, but then implies that file structure is only indicative with (for people using primarily setup.cfg)

If you create a setup.py file, this will enable direct interaction with setup.py (which generally should be avoided), and editable installs. This file used to be required, but can be omitted in modern setuptools.

2 Answers

You need not have a setup.cfg file, if you have a setup.py file. One use of setup.cfg is to override the defaults mentioned in setup.py file. If you look at popular libs we still use setup.py file for packaging / distribution.

There is a shift to move over to sole use of setup.cfg as it's a safer option. From second link you provided.

Transitioning from setup.py to setup.cfg¶ To avoid executing arbitrary scripts and boilerplate code, we are transitioning into a full-fledged setup.cfg to declare your package information instead of running setup(). This inevitably brings challenges due to a different syntax. Here we provide a quick guide to understanding how setup.cfg is parsed by setuptool to ease the pain of transition.

I believe the functionality is dependent on the version of setuptools that is installed.

Related