From 9bdcacd099e1010ec4e077c5cb471d47e692f8ab Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Wed, 13 Aug 2025 21:45:59 -0700 Subject: [PATCH] Drop Python 2 support and require Python 3.7+ - Updated `requires-python` to `>=3.7, <4` - Removed Python 2.x classifiers and setuptools fallback - Switched build backend to `hatchling.build` - Added Python 3.13 classifier - Updated release notes and migration guide to reflect change - Removed unused `build_backend.py` and `setup.py` from sdist --- build_backend.py | 9 ---- doc/release/migration_notes.rst | 7 +++ doc/release/release_notes.rst | 5 +++ pyproject.toml | 13 +++--- setup.py | 78 --------------------------------- 5 files changed, 17 insertions(+), 95 deletions(-) delete mode 100644 build_backend.py delete mode 100644 setup.py diff --git a/build_backend.py b/build_backend.py deleted file mode 100644 index 3979aa9..0000000 --- a/build_backend.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Custom backend to ensure compatibility with Python 2.7. -""" - -import sys - -if sys.version_info[0] < 3: - from setuptools.build_meta import * -else: - from hatchling.build import * diff --git a/doc/release/migration_notes.rst b/doc/release/migration_notes.rst index 2d6cafe..48cc712 100644 --- a/doc/release/migration_notes.rst +++ b/doc/release/migration_notes.rst @@ -6,3 +6,10 @@ Migration notes This section will show more detailed information when relevant for switching to a new version, such as when upgrading involves backwards incompatibilities. + +.. _release/migration/1.0.0: + +Migrate to 1.0.0 +================ + +Dropped support for Python 2.x. The minimum supported version is now Python 3.7. diff --git a/doc/release/release_notes.rst b/doc/release/release_notes.rst index c5d322c..e2bb625 100644 --- a/doc/release/release_notes.rst +++ b/doc/release/release_notes.rst @@ -6,6 +6,11 @@ Release Notes .. release:: Upcoming + .. change:: changed + + Dropped support for Python 2.x. The minimum supported version is now + Python 3.7. + .. change:: new Added compatibility with CMake 4.1. diff --git a/pyproject.toml b/pyproject.toml index 091c7d3..4dc51d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,18 +1,16 @@ [build-system] requires = [ - "hatchling >= 1.4; python_version >= '3'", - "setuptools >= 44; python_version < '3'", + "hatchling >= 1.4", "cmake >= 3.20, < 4.2" ] -build-backend = "build_backend" -backend-path = ["."] +build-backend = "hatchling.build" [project] name = "pytest-cmake" version = "0.13.0" description = "Provide CMake module for Pytest" readme = "README.md" -requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4" +requires-python = ">=3.7, <4" license = {file = "LICENSE"} keywords = ["cmake", "pytest", "development"] authors = [ @@ -25,8 +23,6 @@ classifiers = [ "Intended Audience :: Developers", "Topic :: Software Development :: Build Tools", "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", @@ -34,6 +30,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] [project.urls] @@ -56,4 +53,4 @@ path = "build_config.py" only-include = ["*.cmake"] [tool.hatch.build.targets.sdist] -only-include = ["cmake", "build_config.py", "build_backend.py", "setup.py"] +only-include = ["cmake", "build_config.py"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 0885a07..0000000 --- a/setup.py +++ /dev/null @@ -1,78 +0,0 @@ -"""Setuptools config only used for Python 2.7 compatibility. -""" - -from setuptools import setup -from setuptools.command.install import install - -import os -import subprocess - - -ROOT = os.path.dirname(os.path.realpath(__file__)) -DEPENDENCIES = ["pytest >= 4, < 9"] - - -class CreateCmakeConfig(install): - """Custom command to create and share pytest config.""" - - def run(self): - """Execute builder.""" - import pytest - - build_path = os.path.join(ROOT, "build") - if not os.path.exists(build_path): - os.makedirs(build_path) - - # CMake search procedure is limited to CMake package configuration files - # and does not work with modules. Hence, we are generating a - # configuration file based on the CMake modules created. - # https://cmake.org/cmake/help/latest/command/find_package.html - config_path = os.path.join(build_path, "PytestConfig.cmake") - with open(config_path, "w") as stream: - stream.write( - "include(${CMAKE_CURRENT_LIST_DIR}/FindPytest.cmake)\n" - ) - - # Generate CMake config version file for client to target a specific - # version of Pytest within CMake projects. - version_config_path = os.path.join( - build_path, "PytestConfigVersion.cmake" - ) - script_path = os.path.join( - build_path, "PytestConfigVersionScript.cmake" - ) - with open(script_path, "w") as stream: - stream.write( - "include(CMakePackageConfigHelpers)\n" - "write_basic_package_version_file(\n" - " \"{path}\"\n" - " VERSION {version}\n" - " COMPATIBILITY AnyNewerVersion\n" - ")".format( - path=str(version_config_path), - version=pytest.__version__, - ) - ) - - subprocess.call(["cmake", "-P", str(script_path), "-VV"]) - return install.run(self) - - -setup( - name="pytest-cmake", - version="0.13.0", - data_files=[ - ( - "share/Pytest/cmake", - [ - "build/PytestConfig.cmake", - "build/PytestConfigVersion.cmake", - "cmake/FindPytest.cmake", - "cmake/PytestAddTests.cmake" - ] - ) - ], - cmdclass={"install": CreateCmakeConfig}, - install_requires=DEPENDENCIES, - setup_requires=DEPENDENCIES, -)