Wefti

Python C++ extensions with Wefti and scikit-build-core

Python packages with C or C++ code reach CMake through scikit-build-core. Wefti can be the CMake that those builds run, and it makes the CMake side easier to debug.

The wefti-cmake wheel installs cmake, ctest, cpack, and ccmake as names for Wefti, so a build that calls cmake runs Wefti in compatibility mode with CMake 4.5.1 behavior. The native wefti command adds the probe cache by default, replay, and tools such as wefti explain. In compatibility mode, WEFTI_PROBE_CACHE=on turns on the probe cache alone. Run pip install wefti-cmake to add the CMake commands. scripts/build-wheels.py builds the wefti and wefti-cmake wheels from release archives.

How Wefti fits a Python build

scikit-build-core, pybind11, nanobind, and Cython extensions all end in a CMake project. A wheel build runs cmake to configure and build that project. If the cmake that it finds is Wefti, the configure step follows CMake 4.5.1 rules. In v0.4.0, Wefti matched CMake 4.5.1 in all 27,953 / 27,953 upstream RunCMake cases.

Compatibility mode uses the probe cache when you set WEFTI_PROBE_CACHE=on. WEFTI_ORACLE_MODE=1 keeps the cache off. Configure replay and partial Ninja generation apply when you configure with the native wefti command.

Wefti v0.4.0 has 43 Rust crates. The standalone macOS arm64 executable is 17.50 MiB (18,352,560 bytes). For a native Ninja build, wefti build uses the built-in Ninja 1.13.2 executor. A wheel build that calls cmake --build follows CMake 4.5.1 behavior.

Wefti wheels
WheelCommands it installs
weftiwefti and wefti-lsp, with the bundled CMake data
wefti-cmakecmake, ctest, cpack, and ccmake, which run the same version of Wefti

uv pip install wefti-cmake installs from PyPI. Use --find-links dist/wheels to use locally built wheels. Install wefti-cmake only in environments where cmake should run Wefti.

Share the probe cache between virtualenvs

The probe cache lives in a user-level cache directory, not inside a virtualenv or a build tree. Every virtualenv and every new build directory that uses the native wefti command reads the same verified results. A new environment then skips compiler checks that already ran with the same compiler.

Entries hold only when the compiler bytes and path match. Use wefti cache status to inspect the cache and WEFTI_PROBE_CACHE_DIR to move it. In CI, move the cache between runners with wefti cache export and wefti cache import --sha256.

Debug pybind11 and nanobind with wefti explain

A failing find_package(pybind11 CONFIG) or find_package(nanobind CONFIG) is a common reason for a broken extension build. wefti explain shows how each package was found, or why a config file was rejected.

wefti explain --find pybind11 -B build
wefti explain why-not nanobind -B build --all-candidates
wefti explain my_ext -B build --include /usr/include/python3.12
wefti unused -B build

wefti explain works in memory and changes no file. wefti unused reports packages that the project finds but does not use.

Use Wefti in a Python extension project

Do these steps in a copy of your project first.

  1. Optional. Build the wheels locally. Put the release archives and SHA256SUMS.txt in dist/, then run python3 scripts/build-wheels.py --dist dist --out-dir dist/wheels.
  2. Install the wheel. Run pip install wefti for wefti and wefti-lsp. Run pip install wefti-cmake where cmake must run Wefti.
  3. Check that find_package works. Run wefti explain --find pybind11 -B build or wefti explain why-not nanobind -B build --all-candidates when a package is not found.
  4. Configure the extension with wefti. Run wefti -S . -B build -G Ninja for the C++ side of your project. Run wefti build build to use the built-in Ninja executor.

Frequently asked questions

Is there a pip install cmake alternative?

Wefti has a wefti-cmake wheel that installs cmake, ctest, cpack, and ccmake as names for Wefti. Install it with pip install wefti-cmake. You can also build the wheel from release archives with scripts/build-wheels.py.

Does Wefti work with scikit-build-core?

Put the directory with the Wefti compatibility cmake symlink first on PATH. With scikit-build-core 0.8.0 or later, you can also set CMAKE_EXECUTABLE to that symlink. Before you switch, run wefti verify to compare your configure results with CMake 4.5.1.

Does it make Python wheel builds faster?

The v0.4.0 benchmarks measure configure time in C and C++ projects. To check wheel build time, measure the full build with each tool in the same environment.

Does it work with pybind11, nanobind, and Cython?

These tools all use CMake through find_package() or helper modules. Wefti follows CMake 4.5.1 rules for those calls. Use wefti explain --find to debug a package that is not found.

Can uv install Wefti?

Yes. Run uv pip install wefti-cmake. To use a local wheel, add --find-links dist/wheels.

How do I share the cache between virtualenvs?

Use the native wefti command. The probe cache is in a user-level directory, so every environment reads it. WEFTI_PROBE_CACHE_DIR changes its location.