From 68515abf97dfc769c9aed2ba457ed7b8b2580a5c Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Mon, 12 Aug 2024 11:54:29 -0700 Subject: [PATCH] Drop use of setup.py and setup.cfg (#81443) --- .gitignore | 2 + MANIFEST.in | 1 - pyproject.toml | 109 ++++++++++++++++++ setup.cfg | 106 ----------------- setup.py | 29 ----- .../_internal/classification/__init__.py | 2 - test/sanity/code-smell/package-data.py | 14 ++- 7 files changed, 120 insertions(+), 143 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 8b244f60ee7..57019fd1ab6 100644 --- a/.gitignore +++ b/.gitignore @@ -92,6 +92,8 @@ Vagrantfile /lib/ansible_base.egg-info/ # First used in the `devel` branch during Ansible 2.11 development. /lib/ansible_core.egg-info/ +# First used in the `devel` branch during Ansible 2.18 development. +/ansible_core.egg-info/ # vendored lib dir lib/ansible/_vendor/* !lib/ansible/_vendor/__init__.py diff --git a/MANIFEST.in b/MANIFEST.in index cc03ebcbe9e..fa609f52e9a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,4 @@ include COPYING -include bin/* include changelogs/CHANGELOG*.rst include changelogs/changelog.yaml include licenses/*.txt diff --git a/pyproject.toml b/pyproject.toml index f78c29c152d..6561a22f832 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,112 @@ [build-system] requires = ["setuptools >= 66.1.0, <= 72.1.0"] # lower bound to support controller Python versions, upper bound for latest version tested at release build-backend = "setuptools.build_meta" + +[project] +requires-python = ">=3.11" +name = "ansible-core" +authors = [ + {name = "Ansible Project"}, +] +description = "Radically simple IT automation" +readme = "README.md" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Natural Language :: English", + "Operating System :: POSIX", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3 :: Only", + "Topic :: System :: Installation/Setup", + "Topic :: System :: Systems Administration", + "Topic :: Utilities", +] +dynamic = ["version", "dependencies"] + +[project.urls] +"Homepage" = "https://ansible.com/" +"Source Code" = "https://github.com/ansible/ansible/" +"Bug Tracker" = "https://github.com/ansible/ansible/issues/" +"CI: Azure Pipelines" = "https://dev.azure.com/ansible/ansible/" +"Documentation" = "https://docs.ansible.com/ansible-core/" +"Code of Conduct" = "https://docs.ansible.com/ansible/latest/community/code_of_conduct.html" + +[tool.setuptools.dynamic] +version = {attr = "ansible.release.__version__"} +dependencies = {file = "requirements.txt"} + +[tool.setuptools] +include-package-data = false +license-files = [ + "COPYING", + "licenses/*.txt", +] + +[tool.setuptools.packages.find] +where = ["lib", "test/lib"] + +[tool.setuptools.package-data] +ansible = [ + "config/*.yml", + "executor/powershell/*.ps1", + "galaxy/data/COPYING", + "galaxy/data/*.yml", + "galaxy/data/*/*.j2", + "galaxy/data/*/*.md", + "galaxy/data/*/*/*.cfg", + "galaxy/data/*/*/*.j2", + "galaxy/data/*/*/*.md", + "galaxy/data/*/*/*/*.j2", + "galaxy/data/*/*/*/*.yml", + "galaxy/data/*/*/*/.git_keep", + "galaxy/data/*/*/*/inventory", + "galaxy/data/*/*/.git_keep", + "galaxy/data/*/*/inventory", + "keyword_desc.yml", + "module_utils/csharp/*.cs", + "module_utils/powershell/*.psm1", + "plugins/*/*.yml", +] +ansible_test = [ + "_data/*/*.in", + "_data/*/*.ps1", + "_data/*/*.txt", + "_data/*/*.yml", + "_data/*/*/*.ini", + "_data/ansible.cfg", + "_data/coveragerc", + "_util/*/*/*.ps1", + "_util/*/*/*.py", + "_util/*/*/*.sh", + "_util/*/*/*/*.ini", + "_util/*/*/*/*.json", + "_util/*/*/*/*.ps1", + "_util/*/*/*/*.psd1", + "_util/*/*/*/*.py", + "_util/*/*/*/*.txt", + "_util/*/*/*/*/*.cfg", + "_util/*/*/*/*/*.ps1", + "_util/*/*/*/*/*.py", + "_util/*/*/*/*/*.yml", + "config/*.template", + "config/*.yml", +] + +[project.scripts] +ansible = "ansible.cli.adhoc:main" +ansible-config = "ansible.cli.config:main" +ansible-console = "ansible.cli.console:main" +ansible-doc = "ansible.cli.doc:main" +ansible-galaxy = "ansible.cli.galaxy:main" +ansible-inventory = "ansible.cli.inventory:main" +ansible-playbook = "ansible.cli.playbook:main" +ansible-pull = "ansible.cli.pull:main" +ansible-vault = "ansible.cli.vault:main" +ansible-test = "ansible_test._util.target.cli.ansible_test_cli_stub:main" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 25a285f254b..00000000000 --- a/setup.cfg +++ /dev/null @@ -1,106 +0,0 @@ -# Minimum target setuptools 66.1.0 - -[metadata] -name = ansible-core -version = attr: ansible.release.__version__ -description = Radically simple IT automation -long_description = file: README.md -long_description_content_type = text/markdown -author = Ansible, Inc. -author_email = info@ansible.com -url = https://ansible.com/ -project_urls = - Bug Tracker=https://github.com/ansible/ansible/issues - CI: Azure Pipelines=https://dev.azure.com/ansible/ansible/ - Code of Conduct=https://docs.ansible.com/ansible/latest/community/code_of_conduct.html - Documentation=https://docs.ansible.com/ansible-core/ - Mailing lists=https://docs.ansible.com/ansible/latest/community/communication.html#mailing-list-information - Source Code=https://github.com/ansible/ansible -license = GPLv3+ -classifiers = - Development Status :: 5 - Production/Stable - Environment :: Console - Intended Audience :: Developers - Intended Audience :: Information Technology - Intended Audience :: System Administrators - License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) - Natural Language :: English - Operating System :: POSIX - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Programming Language :: Python :: 3 :: Only - Topic :: System :: Installation/Setup - Topic :: System :: Systems Administration - Topic :: Utilities - -[options] -zip_safe = False -python_requires = >=3.11 -# keep ansible-test as a verbatim script to work with editable installs, since it needs to do its -# own package redirection magic that's beyond the scope of the normal `ansible` path redirection -# done by setuptools `develop` -scripts = - bin/ansible-test - -[options.package_data] -ansible = - config/*.yml - executor/powershell/*.ps1 - galaxy/data/COPYING - galaxy/data/*.yml - galaxy/data/*/*.j2 - galaxy/data/*/*.md - galaxy/data/*/*/*.cfg - galaxy/data/*/*/*.j2 - galaxy/data/*/*/*.md - galaxy/data/*/*/*/*.j2 - galaxy/data/*/*/*/*.yml - galaxy/data/*/*/*/.git_keep - galaxy/data/*/*/*/inventory - galaxy/data/*/*/.git_keep - galaxy/data/*/*/inventory - keyword_desc.yml - module_utils/csharp/*.cs - module_utils/powershell/*.psm1 - plugins/*/*.yml -ansible_test = - _data/*/*.in - _data/*/*.ps1 - _data/*/*.txt - _data/*/*.yml - _data/*/*/*.ini - _data/ansible.cfg - _data/coveragerc - _util/*/*/*.ps1 - _util/*/*/*.py - _util/*/*/*.sh - _util/*/*/*/*.ini - _util/*/*/*/*.json - _util/*/*/*/*.ps1 - _util/*/*/*/*.psd1 - _util/*/*/*/*.py - _util/*/*/*/*.txt - _util/*/*/*/*/*.cfg - _util/*/*/*/*/*.ps1 - _util/*/*/*/*/*.py - _util/*/*/*/*/*.yml - config/*.template - config/*.yml - -# setuptools 51.0.0 -# [options.entry_points] -# console_scripts = -# ansible = ansible.cli.adhoc:main -# ansible-config = ansible.cli.config:main -# ansible-console = ansible.cli.console:main -# ansible-doc = ansible.cli.doc:main -# ansible-galaxy = ansible.cli.galaxy:main -# ansible-inventory = ansible.cli.inventory:main -# ansible-playbook = ansible.cli.playbook:main -# ansible-pull = ansible.cli.pull:main -# ansible-vault = ansible.cli.vault:main -# ansible-test = ansible_test._util.target.cli.ansible_test_cli_stub:main - -[flake8] -max-line-length = 160 diff --git a/setup.py b/setup.py deleted file mode 100644 index 7f56b203d96..00000000000 --- a/setup.py +++ /dev/null @@ -1,29 +0,0 @@ -from __future__ import annotations - -import pathlib - -from setuptools import find_packages, setup - -here = pathlib.Path(__file__).parent.resolve() - -install_requires = (here / 'requirements.txt').read_text(encoding='utf-8').splitlines() - -setup( - install_requires=install_requires, - package_dir={'': 'lib', - 'ansible_test': 'test/lib/ansible_test'}, - packages=find_packages('lib') + find_packages('test/lib'), - entry_points={ - 'console_scripts': [ - 'ansible=ansible.cli.adhoc:main', - 'ansible-config=ansible.cli.config:main', - 'ansible-console=ansible.cli.console:main', - 'ansible-doc=ansible.cli.doc:main', - 'ansible-galaxy=ansible.cli.galaxy:main', - 'ansible-inventory=ansible.cli.inventory:main', - 'ansible-playbook=ansible.cli.playbook:main', - 'ansible-pull=ansible.cli.pull:main', - 'ansible-vault=ansible.cli.vault:main', - ], - }, -) diff --git a/test/lib/ansible_test/_internal/classification/__init__.py b/test/lib/ansible_test/_internal/classification/__init__.py index b51228495c1..352e4764bba 100644 --- a/test/lib/ansible_test/_internal/classification/__init__.py +++ b/test/lib/ansible_test/_internal/classification/__init__.py @@ -834,8 +834,6 @@ class PathMapper: 'MANIFEST.in', 'pyproject.toml', 'requirements.txt', - 'setup.cfg', - 'setup.py', ): return packaging diff --git a/test/sanity/code-smell/package-data.py b/test/sanity/code-smell/package-data.py index 1a5ff3d3796..4719d86c112 100644 --- a/test/sanity/code-smell/package-data.py +++ b/test/sanity/code-smell/package-data.py @@ -24,6 +24,7 @@ def collect_sdist_files(complete_file_list: list[str]) -> list[str]: '.cherry_picker.toml', '.git*', '.mailmap', + 'bin/*', 'changelogs/README.md', 'changelogs/config.yaml', 'changelogs/fragments/*', @@ -37,13 +38,13 @@ def collect_sdist_files(complete_file_list: list[str]) -> list[str]: 'SOURCES.txt', 'dependency_links.txt', 'entry_points.txt', - 'not-zip-safe', 'requires.txt', 'top_level.txt', ) sdist_files.append('PKG-INFO') - sdist_files.extend(f'lib/ansible_core.egg-info/{name}' for name in egg_info) + sdist_files.append('setup.cfg') + sdist_files.extend(f'ansible_core.egg-info/{name}' for name in egg_info) return sdist_files @@ -51,8 +52,12 @@ def collect_sdist_files(complete_file_list: list[str]) -> list[str]: def collect_wheel_files(complete_file_list: list[str]) -> list[str]: """Return a list of files which should be present in the wheel.""" wheel_files = [] + license_files = [] for path in complete_file_list: + if path.startswith('licenses/'): + license_files.append(os.path.relpath(path, 'licenses')) + if path.startswith('lib/ansible/'): prefix = 'lib' elif path.startswith('test/lib/ansible_test/'): @@ -62,16 +67,15 @@ def collect_wheel_files(complete_file_list: list[str]) -> list[str]: wheel_files.append(os.path.relpath(path, prefix)) - dist_info = ( + dist_info = [ 'COPYING', 'METADATA', 'RECORD', 'WHEEL', 'entry_points.txt', 'top_level.txt', - ) + ] + license_files - wheel_files.append(f'ansible_core-{__version__}.data/scripts/ansible-test') wheel_files.extend(f'ansible_core-{__version__}.dist-info/{name}' for name in dist_info) return wheel_files