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, replay, and tools such as wefti explain. Wefti is not on PyPI yet. 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.3.0, Wefti matched CMake 4.5.1 in 27,953 / 27,953 upstream RunCMake cases.

Compatibility mode is strict on purpose. It turns off the probe cache, replay, and Ninja generation skip. Those features belong to the native wefti command, so speed comes from calling wefti on the C++ side of the project, in CI, and in your own test builds. The project has not published a result for scikit-build-core, pybind11, nanobind, or Cython builds, so measure your own wheel build before you rely on a gain.

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 --find-links dist/wheels wefti-cmake works the same way as pip. 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. Build the wheels. 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 --find-links dist/wheels wefti for wefti and wefti-lsp, or wefti-cmake where cmake should 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 for the C++ side of your project, then build with cmake --build build.

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. It is not on PyPI yet. Build the wheel from a release with scripts/build-wheels.py.

Does Wefti work with scikit-build-core?

scikit-build-core runs a cmake program. When that program is Wefti, it behaves like CMake 4.5.1. The project has not published a scikit-build-core test result, so try it on a copy of your project.

Does it make Python wheel builds faster?

The probe cache, replay, and Ninja skip run only in the native wefti command, and a build that calls cmake uses compatibility mode. There is no published wheel benchmark. The C++ side of a project that you configure with wefti gets the speedups.

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, from a local wheel. Run uv pip install --find-links dist/wheels wefti-cmake after you build the wheels. Wefti is not on PyPI yet.

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.