{"library":"cmake","title":"CMake (Python distribution)","description":"CMake is an open-source, cross-platform family of tools designed to build, test, and package software. The `cmake` Python package provides Python wheels for the CMake executable, making it easy to install and use CMake within Python environments. It is currently at version 4.3.1 and typically releases new versions in sync with upstream CMake releases.","status":"active","version":"4.3.1","language":"en","source_language":"en","source_url":"https://github.com/scikit-build/cmake-python-distributions","tags":["build system","cross-platform","C++","native extensions","build tool"],"install":[{"cmd":"pip install cmake","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The `cmake` Python package provides the path to the bundled CMake executable. Direct programmatic execution of CMake commands should be done via `subprocess` using this path, not via a high-level Python API within the `cmake` package itself. For integrating CMake with Python package builds, consider `scikit-build` or `scikit-build-core`.","wrong":"from cmake import build_system","symbol":"cmake_path","correct":"import cmake\ncmake_executable = cmake.cmake_path()"},{"note":"Returns the version string of the bundled CMake executable.","symbol":"cmake_version","correct":"import cmake\nversion_str = cmake.cmake_version()"}],"quickstart":{"code":"import cmake\nimport subprocess\nimport sys\n\ntry:\n    cmake_executable = cmake.cmake_path()\n    print(f\"Found CMake executable at: {cmake_executable}\")\n\n    # Run a simple CMake command, e.g., --version\n    result = subprocess.run([cmake_executable, '--version'], capture_output=True, text=True, check=True)\n    print(\"\\nCMake --version output:\")\n    print(result.stdout)\n\n    # Example of getting CMake version programmatically\n    print(f\"\\nCMake version from package: {cmake.cmake_version()}\")\n\nexcept subprocess.CalledProcessError as e:\n    print(f\"Error running CMake: {e}\", file=sys.stderr)\n    print(f\"Stderr: {e.stderr}\", file=sys.stderr)\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\", file=sys.stderr)\n","lang":"python","description":"This quickstart demonstrates how to retrieve the path to the CMake executable provided by the `cmake` package and execute a basic CMake command using Python's `subprocess` module. It also shows how to get the version string directly from the `cmake` package."},"warnings":[{"fix":"Upgrade your Python version to 3.8+ or pin the `cmake` package version to `~=4.0.3` for Python 3.7, or `~=3.22` for older manylinux.","message":"Python 3.7 and older `manylinux` wheels were dropped in CMake Python distribution version 4.1.0. If you require Python 3.7 or older `manylinux` environments (e.g., `manylinux2010`, `manylinux1`), you must use an older version of the `cmake` package (e.g., 4.0.3 for Python 3.7/manylinux2010, 3.22.x for manylinux1).","severity":"breaking","affected_versions":">=4.1.0"},{"fix":"Use `subprocess` to execute CMake commands via `cmake.cmake_path()`. If building Python C/C++/Fortran extensions with CMake, use `scikit-build` or `scikit-build-core` as your build backend.","message":"The `cmake` Python package primarily serves to provide a convenient, platform-specific distribution of the CMake *executable*. It does not offer a high-level Python API for interacting with CMake's build system features directly within Python. For building Python extension modules using CMake, consider higher-level build backends like `scikit-build` or `scikit-build-core` which utilize this `cmake` package.","severity":"gotcha","affected_versions":"All"},{"fix":"Migrate your `CMakeLists.txt` files to use the modern `find_package(Python3 COMPONENTS Interpreter Development)` command.","message":"Older CMake modules `FindPythonInterp` and `FindPythonLibs` are deprecated and are no-ops since CMake 3.27. Using them in `CMakeLists.txt` will not correctly find Python installations with modern CMake versions.","severity":"deprecated","affected_versions":"All versions of CMake provided by this package (4.x)"},{"fix":"Explicitly add necessary directories to `CMAKE_PREFIX_PATH` or `CMAKE_LIBRARY_PATH` in your `CMakeLists.txt` or via command-line options when configuring CMake.","message":"CMake 3.28 (and subsequent versions distributed by this package) changed the `PATH` behavior for Windows, where `find_{library,path,file}()` no longer searches the system `PATH` by default. This might break existing projects that rely on `PATH` for finding libraries on Windows.","severity":"breaking","affected_versions":">=3.28"},{"fix":"Update your `CMakeLists.txt` to specify `cmake_minimum_required(VERSION X.Y)` with `X.Y` being at least 3.5, or preferably a more recent version (e.g., 3.15+ for improved `FindPython` modules).","message":"CMake 3.5 compatibility was removed. Calls to `cmake_minimum_required()` or `cmake_policy()` setting policy versions below 3.5 will now result in an error.","severity":"breaking","affected_versions":">=4.0"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}