--- id: pytest-cmake version: "1.3.0" license: MIT License Copyright (c) 2022 Jeremy Retailleau Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) license_treatment: permissive maintenance: aging --- # pytest-cmake — Provide CMake module for Pytest License: permissive · Maintenance: aging · Downloads: 269.7K/mo ## What it is and what it does pytest-cmake is a CMake module that bridges Pytest and CMake, allowing Python tests to be discovered and run as part of a C++ project's build system. It provides a find_package function to locate Pytest and a pytest_discover_tests function that automatically converts Python tests into CTest entries, which can then be executed and reported alongside native C++ tests. The package is designed for mixed-language projects—particularly those with C++ libraries that expose Python bindings. Instead of running Python tests separately, developers can integrate them into their CMake workflow, controlling test environment variables like library and Python paths, filtering test names, and declaring dependencies on compiled targets. Use it for: - Integrate Python unit tests for C++ extension modules into a unified CMake test suite - Automatically discover and register Python tests as CTest entries without manual configuration - Set up controlled test environments by prepending library and Python paths before test execution - Run mixed C++ and Python tests in a single CI/CD pipeline using ctest ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Integrates Pytest with CMake build systems, enabling automatic discovery and execution of Python tests as part of C++ project builds. Yes, if you maintain a CMake project with Python tests or C++ code with Python bindings. The package has low install friction, permissive licensing, and no known vulnerabilities. The aging maintenance status is a minor concern for a stable, narrowly-scoped integration tool, but the repository remains active and supports current Python versions. ## Install pip install pytest-cmake uv add pytest-cmake poetry add pytest-cmake ## Installing pytest-cmake Before you install: Low friction install with a single runtime dependency on pytest. Last release was 223 days ago; repository is active but aging. License in practice: MIT License permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and proprietary projects. Quickstart: pip install pytest-cmake In CMakeLists.txt: find_package(Pytest 8.2.1 REQUIRED) pytest_discover_tests(PythonTest LIBRARY_PATH_PREPEND $) Requires CMake and pytest to be installed; pytest-cmake is a CMake module, not a standalone Python tool Verify before relying: - Whether the package works with pytest versions outside the range shown in the description example (8.2.1) - Performance characteristics when discovering large numbers of Python tests in a single CMake project ## Package facts - License: MIT License Copyright (c) 2022 Jeremy Retailleau Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 269.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags cmake pytest integration, python testing in cmake, ctest pytest discovery, cmake find_package pytest, c++ python test automation, cmake python bindings testing, cmake-integration, mixed-language-testing [View on SkillFed](https://skillfed.io/packages/pytest-cmake) · [View on PyPI](https://pypi.org/project/pytest-cmake/)