From 1b354cfa6382745855f4c47b84a151302f56cba8 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 20 May 2024 02:45:05 -0400 Subject: [PATCH] chore: move to hatchling (#1297) --- .circleci/prepare.sh | 4 +- .pre-commit-config.yaml | 6 --- MANIFEST.in | 6 --- bin/bump_version.py | 16 +++--- pyproject.toml | 107 +++++++++++++++++++++++++++++++++------- setup.cfg | 57 --------------------- setup.py | 38 -------------- 7 files changed, 101 insertions(+), 133 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.circleci/prepare.sh b/.circleci/prepare.sh index 991f0202a..21a8dde60 100644 --- a/.circleci/prepare.sh +++ b/.circleci/prepare.sh @@ -4,7 +4,9 @@ set -o xtrace $PYTHON --version $PYTHON -m pip --version -$PYTHON -m virtualenv -p "$PYTHON" venv +$PYTHON -m virtualenv --version +$PYTHON -m virtualenv --no-setuptools --no-wheel -p "$PYTHON" venv +venv/bin/python -m pip install -U pip venv/bin/python -m pip install -e ".[dev]" venv/bin/python -m pip freeze venv/bin/python --version diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 31c1d7ed6..171d6e379 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,12 +20,6 @@ repos: args: ["--fix", "--show-fixes"] - id: ruff-format -- repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.5.0 - hooks: - - id: setup-cfg-fmt - args: [--include-version-classifiers, --min-py-version=3.8, --max-py-version=3.12] - - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.10.0 hooks: diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 6fc0b3942..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -recursive-include cibuildwheel *.cfg -recursive-include cibuildwheel *.in -recursive-include cibuildwheel *.py -recursive-include cibuildwheel *.toml -recursive-include cibuildwheel *.txt -recursive-include cibuildwheel *.typed diff --git a/bin/bump_version.py b/bin/bump_version.py index 00b0fc1e4..e28bdcb97 100755 --- a/bin/bump_version.py +++ b/bin/bump_version.py @@ -1,13 +1,12 @@ #!/usr/bin/env python3 # /// script -# dependencies = ["click", "packaging"] +# dependencies = ["click", "packaging", "tomli; python_version<'3.11'"] # /// from __future__ import annotations -import configparser import glob import os import subprocess @@ -18,8 +17,14 @@ import click from packaging.version import InvalidVersion, Version +if sys.version_info < (3, 11): + import tomli as tomllib +else: + import tomllib + config = [ # file path, version find/replace format + ("pyproject.toml", 'version = "{}"'), ("README.md", "cibuildwheel=={}"), ("cibuildwheel/__init__.py", '__version__ = "{}"'), ("docs/faq.md", "cibuildwheel=={}"), @@ -27,7 +32,6 @@ ("docs/setup.md", "cibuildwheel=={}"), ("examples/*", "cibuildwheel=={}"), ("examples/*", "cibuildwheel@v{}"), - ("setup.cfg", "version = {}"), ] RED = "\u001b[31m" @@ -37,10 +41,8 @@ @click.command() def bump_version() -> None: - # Update if moving setup.cfg to pyproject.toml - cfg = configparser.ConfigParser() - cfg.read("setup.cfg") - current_version = cfg["metadata"]["version"] + with open("pyproject.toml", "rb") as f: + current_version = tomllib.load(f)["project"]["version"] try: commit_date_str = subprocess.run( diff --git a/pyproject.toml b/pyproject.toml index ca0f39d9d..342394af1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,94 @@ [build-system] -requires = [ - "setuptools>=42", +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "cibuildwheel" +version = "2.18.0" +description = "Build Python wheels on CI with minimal configuration." +readme = "README.md" +license = "BSD-2-Clause" +requires-python = ">=3.8" +authors = [ + { name = "Joe Rickerby", email = "joerick@mac.com" }, ] -build-backend = "setuptools.build_meta" +keywords = [ + "appveyor", + "ci", + "linux", + "macos", + "packaging", + "pypi", + "travis", + "wheel", + "windows", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Software Development :: Build Tools", +] +dependencies = [ + "bashlex!=0.13", + "bracex", + "certifi", + "filelock", + "packaging>=20.9", + "platformdirs", + "tomli;python_version < '3.11'", + "typing-extensions>=4.1.0;python_version < '3.11'", +] + +[project.optional-dependencies] +bin = [ + "click", + "packaging>=21.0", + "pip-tools", + "pygithub", + "pyyaml", + "requests", + "rich>=9.6", +] +dev = [ + "cibuildwheel[test,bin]", +] +docs = [ + "jinja2>=3.1.2", + "mkdocs-include-markdown-plugin==2.8.0", + "mkdocs-macros-plugin", + "mkdocs==1.3.1", + "pymdown-extensions", +] +test = [ + "build", + "jinja2", + "pytest-timeout", + "pytest-xdist", + "pytest>=6", + "tomli_w", + "validate-pyproject", +] + +[project.scripts] +cibuildwheel = "cibuildwheel.__main__:main" +[project.entry-points."validate_pyproject.tool_schema"] +cibuildwheel = "cibuildwheel.schema:get_schema" + +[project.urls] +Changelog = "https://github.com/pypa/cibuildwheel#changelog" +Documentation = "https://cibuildwheel.pypa.io" +Homepage = "https://github.com/pypa/cibuildwheel" [tool.pytest.ini_options] minversion = "6.0" @@ -57,21 +142,6 @@ module = [ ignore_missing_imports = true -[tool.check-manifest] -ignore = [ - ".*", - ".circleci/**", - "test/**", - "unit_test/**", - "docs/**", - "examples/**", - "bin/**", - "*.yml", - "CI.md", # TODO: can change test/test_ssl and remove this - "requirements-dev.txt", - "noxfile.py", -] - [tool.pylint] py-version = "3.8" jobs = "0" @@ -162,6 +232,7 @@ flake8-unused-arguments.ignore-variadic-names = true [tool.ruff.lint.per-file-ignores] "unit_test/*" = ["PLC1901"] "cibuildwheel/_compat/**.py" = ["TID251"] +"bin/*" = ["TID251"] [tool.repo-review] ignore = ["PC170", "PP303"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index bb62533b0..000000000 --- a/setup.cfg +++ /dev/null @@ -1,57 +0,0 @@ -[metadata] -name = cibuildwheel -version = 2.18.0 -description = Build Python wheels on CI with minimal configuration. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/pypa/cibuildwheel -author = Joe Rickerby -author_email = joerick@mac.com -license = BSD-2-Clause -license_files = LICENSE -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - License :: OSI Approved :: BSD License - Natural Language :: English - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Programming Language :: Python :: Implementation :: CPython - Topic :: Software Development :: Build Tools -keywords = ci,wheel,packaging,pypi,travis,appveyor,macos,linux,windows -project_urls = - Changelog=https://github.com/pypa/cibuildwheel#changelog - Documentation=https://cibuildwheel.pypa.io/ - -[options] -packages = find: -install_requires = - bashlex!=0.13 - bracex - certifi - filelock - packaging>=20.9 - platformdirs - tomli;python_version < '3.11' - typing-extensions>=4.1.0;python_version < '3.11' -python_requires = >=3.8 -include_package_data = True -zip_safe = False - -[options.packages.find] -include = - cibuildwheel - -[options.entry_points] -console_scripts = - cibuildwheel = cibuildwheel.__main__:main -validate_pyproject.tool_schema = - cibuildwheel = cibuildwheel.schema:get_schema - -[options.package_data] -cibuildwheel = resources/* diff --git a/setup.py b/setup.py deleted file mode 100644 index 90f83feda..000000000 --- a/setup.py +++ /dev/null @@ -1,38 +0,0 @@ -from __future__ import annotations - -from setuptools import setup - -extras = { - "docs": [ - "mkdocs-include-markdown-plugin==2.8.0", - "mkdocs==1.3.1", - "jinja2>=3.1.2", - "pymdown-extensions", - "mkdocs-macros-plugin", - ], - "test": [ - "jinja2", - "pytest>=6", - "pytest-timeout", - "pytest-xdist", - "build", - "tomli_w", - "validate-pyproject", - ], - "bin": [ - "click", - "pip-tools", - "pygithub", - "pyyaml", - "requests", - "rich>=9.6", - "packaging>=21.0", - ], -} - -extras["dev"] = [ - *extras["test"], - *extras["bin"], -] - -setup(extras_require=extras)