Confusion about Python's distribution packages

Viewed 64

I'm going over this tutorial about packaging Python projects, and I'm quite confused. It provides an example of creating a distribution package, by creating the following structure:

packaging_tutorial/
├── LICENSE
├── pyproject.toml
├── README.md
├── setup.cfg
├── src/
│   └── example_package/
│       ├── __init__.py
│       └── example.py
└── tests/

The setup.cfg and setup.py files contains pretty much (or exactly) the same data bits. In the "Creating Pyproject.toml" section the tutorial says:

pyproject.toml tells build tools (like pip and build) what is required to build your project. This tutorial uses setuptools, so open pyproject.toml and enter the following content:

When it gets to the "Generating distribution archives" part it says to do this with PyPA's build package.

py -m build

So what I don't understand is: we have three files here: setup.py, setup.cfg and Pyproject.toml. What build system are we using to create the package? Is it setuptools or PyPA build? Which files are required for which system? On the one hand, the tutorial says that we're using setuptools, but then it tells me to run py -m build.. what gives?

My guess is - please correct me if I'm wrong - that setup.py is using setuptools, and if I'm using this file to install the package, I don't need setup.cfg nor Pyproject.toml. I just run

py -m pip install .

And the package is installed on my machine.

0 Answers
Related