In somewhat complex Python setup.py
configurations, one typically needs other libraries already present in order to execute setuptools.setup
. In my case, this would be setuptools>=45.0
and cython>=0.29
. Now, I have two options to declare these build-time requirements (not to confuse with standard package installation requirements typically found in a requirements.txt
file) in order to ship this project to PyPI:
setup.py
in the setup_requires
argument:#setup.py
from setuptools import setup
#...
setup(
name='bla',
#...
setup_requires = ['setuptools>=45.0', 'cython>=0.29'],
)
pyproject.toml
file following PEP518:#pyproject.toml
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools>=45.0", "cython>=0.29"]
Are they exchangeable? Which one should be used and why?
The aforementioned PEP was created to address the limitations of the 1st approach that are listed in the Rationale section. Packaging Python recommends using the 2nd approach.