Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"]
like image 295
gebbissimo Avatar asked Dec 03 '25 17:12

gebbissimo


1 Answers

According to PEP 621, the equivalent field in the [project] table is requires-python.

More information about the list of valid configuration fields can be found in: https://packaging.python.org/en/latest/specifications/declaring-project-metadata/.

The equivalent pyproject.toml of your example would be:

[project]
name = "my_package_name"
requires-python = ">3.5.2"
...
like image 193
Anderson Bravalheri Avatar answered Dec 06 '25 08:12

Anderson Bravalheri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!