Giter Site home page Giter Site logo

cmake_example's Introduction

cmake_example for pybind11

Gitter

CI status
MSVC 2019 AppVeyor
conda.recipe Conda Actions Status
pip builds Pip Actions Status
cibuildwheel Wheels Actions Status

An example pybind11 module built with a CMake-based build system. This is useful for C++ codebases that have an existing CMake project structure. This is being replaced by scikit_build_example, which uses scikit-build-core, which is designed to allow Python packages to be driven from CMake without depending on setuptools. The approach here has some trade-offs not present in a pure setuptools build (see python_example) or scikit-build-core. Python 3.7+ required; see the commit history for older versions of Python.

Problems vs. scikit-build-core based example:

  • You have to manually copy fixes/additions when they get added to this example (like when Apple Silicon support was added)
  • Modern editable installs are not supported (scikit-build-core doesn't support them either yet, but probably will soon)
  • You are depending on setuptools, which can and will change
  • You are stuck with an all-or-nothing approach to adding cmake/ninja via wheels (scikit-build-core adds these only as needed, so it can be used on BSD, Cygwin, Pyodide, Android, etc)
  • You are stuck with whatever CMake ships with (scikit-build-core backports FindPython for you)

Prerequisites

  • A compiler with C++11 support
  • Pip 10+ or CMake >= 3.4 (or 3.14+ on Windows, which was the first version to support VS 2019)
  • Ninja or Pip 10+

Installation

Just clone this repository and pip install. Note the --recursive option which is needed for the pybind11 submodule:

git clone --recursive https://github.com/pybind/cmake_example.git
pip install ./cmake_example

With the setup.py file included in this example, the pip install command will invoke CMake and build the pybind11 module as specified in CMakeLists.txt.

Building the documentation

Documentation for the example project is generated using Sphinx. Sphinx has the ability to automatically inspect the signatures and documentation strings in the extension module to generate beautiful documentation in a variety formats. The following command generates HTML-based reference documentation; for other formats please refer to the Sphinx manual:

  • cd cmake_example/docs
  • make html

License

Pybind11 is provided under a BSD-style license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.

Test call

import cmake_example
cmake_example.add(1, 2)

cmake_example's People

Contributors

dependabot[bot] avatar pre-commit-ci[bot] avatar henryiii avatar dean0x7d avatar ax3l avatar sylvaincorlay avatar youkaichao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.