diff --git a/changelogs/fragments/559-python_requires.yml b/changelogs/fragments/559-python_requires.yml new file mode 100644 index 00000000..4f479462 --- /dev/null +++ b/changelogs/fragments/559-python_requires.yml @@ -0,0 +1,2 @@ +bugfixes: + - "Use the correct directive in ``setup.cfg`` for Ansible 9+ for requiring a Python version, i.e. use ``python_requires`` instead of ``requires_python`` (https://github.com/ansible-community/antsibull/pull/559)." diff --git a/src/antsibull/python_metadata.py b/src/antsibull/python_metadata.py index 881b0cf6..fec80f8c 100644 --- a/src/antsibull/python_metadata.py +++ b/src/antsibull/python_metadata.py @@ -293,7 +293,7 @@ def generate(self) -> None: f"ansible-core ~= {self.ansible_core_version}" ) - self["options"]["requires_python"] = ( + self["options"]["python_requires"] = ( self.python_requires or self.core_python_requires ) @@ -363,7 +363,7 @@ def write(self, file: Path | None = None) -> None: # pylint: disable-next=protected-access collection_directories=self.maker._collection_directories, # - python_requires=self.maker["options"]["requires_python"], + python_requires=self.maker["options"]["python_requires"], PypiVer=PypiVer, ) file.write_text(setup_contents, encoding="utf-8") diff --git a/tests/test_data/package-files/force_setup_cfg/8.1.0/setup.cfg b/tests/test_data/package-files/force_setup_cfg/8.1.0/setup.cfg index 824d8d66..d1d2348d 100644 --- a/tests/test_data/package-files/force_setup_cfg/8.1.0/setup.cfg +++ b/tests/test_data/package-files/force_setup_cfg/8.1.0/setup.cfg @@ -34,7 +34,7 @@ project_urls = zip_safe = False install_requires = ansible-core ~= 2.15.1 -requires_python = >=3.9 +python_requires = >=3.9 package_dir = =. packages = find_namespace: