CMake, the cross-platform build system generator, is now easily installable in Python distributions! This makes creation of cross-platform C/C++ CPython extension modules accessible to many more developers.

To install the CMake Python distribution, run:

  python -m pip install --upgrade pip

  python -m pip install cmake

The official package manager for Python, pip, is available with both Python 2.7 and the recent Python 3. Of course, CMake can also be installed via installers from cmake.org, package managers like apt, Homebrew, or Conda, and it is shipped with developer tools like Visual Studio. And, like the CMake Python Distribution, it is open source, so it can be built from source with any C++ compiler.

 

For more information on the CMake Python Distribution, documentation is available on Read The Docs.

For commercial support in building and packaging your C/C++ extension, please reach out to us at kitware@kitware.com.

5 comments to CMake Python Wheels

  1. Wheels for CMake 3.8.1 have just been uploaded and are also available with python 3.6

  2. Is it just to have another way to download CMake or is it a way to add ability to use CMake from Python?

    I really hope I’m wrong about this but looking at the python package source, I couldn’t find an effective way to call CMake from Python. I saw that the python package has a cmake() function but it only seems to call cmake using the command line arguments. This means that if I wanted to use CMake to build Python CExtensions in my setup.py this wouldn’t work.

  3. Hi Henry,

    The cmake wheel currently installs the cmake/ctest/cpack binaries and ensure it is available from the corresponding python environment.

    There is (currently) no other interface to invoke CMake.

    Instead, if you would like to build Python CExtension using using CMake and python, I invite you to look at http://scikit-build.readthedocs.io

    Let me know if you have any questions,
    Jc

  4. That’s a shame but thanks for the link. I glanced at scikit-build a while back but I remember that was overwhelmed by it. This is why I got excited about this, thinking it would have been a simpler approach to adding CMake to Python. Oh well. I can’t fault you for having another goal with your project. I’ll take another look at scikit-build

  5. The intent of scikit-build is to be a simple and approachable way to write CPython Extensions including compiled code.

    We can definitively improve the documentation and would appreciate any hint. May be you could create an issue (or help improve the documentation 🙂 ). See https://github.com/scikit-build/scikit-build

    Last but not least, if you would like, I could have a look at your project and suggest a way forward.

Leave a Reply