How to define "python_requires" in pyproject.toml using setuptools?

Viewed 406

Setuptools allows you to specify the minimum python version as such:

from setuptools import setup

[...]

setup(name="my_package_name",
      python_requires='>3.5.2',
      [...]

However, how can you do this with the pyproject.toml? The following two things did NOT work:

[project]
...
# ERROR: invalid key 
python_requires = ">=3"

# ERROR: no matching distribution found
dependencies = ["python>=3"]
2 Answers

You can specify this in setup.cfg. For example:

..
[options]
packages = find_namespace:
install_requires =
    matplotlib~=3.5
    numpy~=1.22
python_requires = >=3.8
include_package_data = True
package_dir =
    =src
zip_safe = False

[options.packages.find]
where = src
Related