├── docs ├── cmake_example.rst ├── index.rst ├── Makefile ├── make.bat └── conf.py ├── .gitignore ├── .gitmodules ├── MANIFEST.in ├── tests └── test_basic.py ├── .github ├── dependabot.yml └── workflows │ ├── format.yml │ ├── pip.yml │ ├── conda.yml │ └── wheels.yml ├── CMakeLists.txt ├── conda.recipe └── meta.yaml ├── .appveyor.yml ├── src └── main.cpp ├── pyproject.toml ├── .pre-commit-config.yaml ├── LICENSE ├── README.md └── setup.py /docs/cmake_example.rst: -------------------------------------------------------------------------------- 1 | .. automodule:: cmake_example 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | dist/ 3 | _build/ 4 | _generate/ 5 | *.so 6 | *.py[cod] 7 | *.egg-info 8 | *env* 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "pybind11"] 2 | path = pybind11 3 | url = https://github.com/pybind/pybind11.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.md LICENSE pybind11/LICENSE 2 | graft pybind11/include 3 | graft pybind11/tools 4 | graft src 5 | global-include CMakeLists.txt *.cmake 6 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | cmake_example Documentation 2 | ============================ 3 | 4 | Contents: 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | cmake_example 10 | -------------------------------------------------------------------------------- /tests/test_basic.py: -------------------------------------------------------------------------------- 1 | import cmake_example as m 2 | 3 | 4 | def test_main(): 5 | assert m.__version__ == "0.0.1" 6 | assert m.add(1, 2) == 3 7 | assert m.subtract(1, 2) == -1 8 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Maintain dependencies for GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | groups: 9 | actions: 10 | patterns: 11 | - "*" 12 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4...3.18) 2 | project(cmake_example) 3 | 4 | add_subdirectory(pybind11) 5 | pybind11_add_module(cmake_example src/main.cpp) 6 | 7 | # EXAMPLE_VERSION_INFO is defined by setup.py and passed into the C++ code as a 8 | # define (VERSION_INFO) here. 9 | target_compile_definitions(cmake_example 10 | PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO}) 11 | -------------------------------------------------------------------------------- /.github/workflows/format.yml: -------------------------------------------------------------------------------- 1 | # This is a format job. Pre-commit has a first-party GitHub action, so we use 2 | # that: https://github.com/pre-commit/action 3 | 4 | name: Format 5 | 6 | on: 7 | workflow_dispatch: 8 | pull_request: 9 | push: 10 | branches: 11 | - master 12 | 13 | jobs: 14 | pre-commit: 15 | name: Format 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v4 19 | - uses: actions/setup-python@v5 20 | with: 21 | python-version: "3.x" 22 | - uses: pre-commit/action@v3.0.1 23 | -------------------------------------------------------------------------------- /conda.recipe/meta.yaml: -------------------------------------------------------------------------------- 1 | package: 2 | name: cmake_example 3 | version: 0.0.1 4 | 5 | source: 6 | path: .. 7 | 8 | build: 9 | number: 0 10 | script: {{ PYTHON }} -m pip install . -vvv 11 | 12 | requirements: 13 | build: 14 | - "{{ compiler('cxx') }}" 15 | - cmake 16 | - ninja 17 | 18 | host: 19 | - python 20 | - pip !=22.1.0 21 | 22 | run: 23 | - python 24 | 25 | 26 | test: 27 | requires: 28 | - pytest 29 | imports: 30 | - cmake_example 31 | source_files: 32 | - tests 33 | commands: 34 | - python -m pytest 35 | 36 | about: 37 | summary: A CMake example project built with pybind11. 38 | license_file: LICENSE 39 | -------------------------------------------------------------------------------- /.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{build}' 2 | image: Visual Studio 2019 3 | platform: 4 | - x86 5 | - x64 6 | environment: 7 | global: 8 | DISTUTILS_USE_SDK: 1 9 | PYTHONWARNINGS: ignore:DEPRECATION 10 | MSSdk: 1 11 | matrix: 12 | - PYTHON: 37 13 | install: 14 | - cmd: '"%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM%' 15 | - ps: | 16 | git submodule update -q --init --recursive 17 | if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" } 18 | $env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH" 19 | python -m pip install --disable-pip-version-check --upgrade --no-warn-script-location pip build pytest 20 | build_script: 21 | - ps: | 22 | python -m build -s 23 | cd dist 24 | python -m pip install --verbose cmake_example-0.0.1.tar.gz 25 | cd .. 26 | test_script: 27 | - ps: python -m pytest 28 | -------------------------------------------------------------------------------- /.github/workflows/pip.yml: -------------------------------------------------------------------------------- 1 | name: Pip 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | push: 7 | branches: 8 | - master 9 | 10 | jobs: 11 | build: 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | platform: [windows-latest, macos-13, ubuntu-latest] 16 | python-version: ["3.7", "3.11"] 17 | 18 | runs-on: ${{ matrix.platform }} 19 | 20 | steps: 21 | - uses: actions/checkout@v4 22 | with: 23 | submodules: true 24 | 25 | - uses: actions/setup-python@v5 26 | with: 27 | python-version: ${{ matrix.python-version }} 28 | 29 | - name: Add requirements 30 | run: python -m pip install --upgrade wheel setuptools 31 | 32 | - name: Build and install 33 | run: pip install --verbose .[test] 34 | 35 | - name: Test 36 | run: python -m pytest 37 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define STRINGIFY(x) #x 4 | #define MACRO_STRINGIFY(x) STRINGIFY(x) 5 | 6 | int add(int i, int j) { 7 | return i + j; 8 | } 9 | 10 | namespace py = pybind11; 11 | 12 | PYBIND11_MODULE(cmake_example, m) { 13 | m.doc() = R"pbdoc( 14 | Pybind11 example plugin 15 | ----------------------- 16 | 17 | .. currentmodule:: cmake_example 18 | 19 | .. autosummary:: 20 | :toctree: _generate 21 | 22 | add 23 | subtract 24 | )pbdoc"; 25 | 26 | m.def("add", &add, R"pbdoc( 27 | Add two numbers 28 | 29 | Some other explanation about the add function. 30 | )pbdoc"); 31 | 32 | m.def("subtract", [](int i, int j) { return i - j; }, R"pbdoc( 33 | Subtract two numbers 34 | 35 | Some other explanation about the subtract function. 36 | )pbdoc"); 37 | 38 | #ifdef VERSION_INFO 39 | m.attr("__version__") = MACRO_STRINGIFY(VERSION_INFO); 40 | #else 41 | m.attr("__version__") = "dev"; 42 | #endif 43 | } 44 | -------------------------------------------------------------------------------- /.github/workflows/conda.yml: -------------------------------------------------------------------------------- 1 | name: Conda 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - master 8 | pull_request: 9 | 10 | jobs: 11 | build: 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | platform: [ubuntu-latest, windows-latest, macos-12] 16 | python-version: ["3.8", "3.10"] 17 | 18 | runs-on: ${{ matrix.platform }} 19 | 20 | # The setup-miniconda action needs this to activate miniconda 21 | defaults: 22 | run: 23 | shell: "bash -l {0}" 24 | 25 | steps: 26 | - uses: actions/checkout@v4 27 | with: 28 | submodules: true 29 | 30 | - name: Get conda 31 | uses: conda-incubator/setup-miniconda@v3.0.4 32 | with: 33 | python-version: ${{ matrix.python-version }} 34 | channels: conda-forge 35 | channel-priority: strict 36 | 37 | # Currently conda-build requires the dead package "toml" but doesn't declare it 38 | - name: Prepare 39 | run: conda install conda-build conda-verify pytest toml 40 | 41 | - name: Build 42 | run: conda build conda.recipe 43 | 44 | - name: Install 45 | run: conda install -c ${CONDA_PREFIX}/conda-bld/ cmake_example 46 | 47 | - name: Test 48 | run: python -m pytest 49 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "wheel", 5 | "ninja", 6 | "cmake>=3.12", 7 | ] 8 | build-backend = "setuptools.build_meta" 9 | 10 | [tool.mypy] 11 | files = "setup.py" 12 | python_version = "3.7" 13 | strict = true 14 | show_error_codes = true 15 | enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] 16 | warn_unreachable = true 17 | 18 | [[tool.mypy.overrides]] 19 | module = ["ninja"] 20 | ignore_missing_imports = true 21 | 22 | 23 | [tool.pytest.ini_options] 24 | minversion = "6.0" 25 | addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] 26 | xfail_strict = true 27 | filterwarnings = [ 28 | "error", 29 | "ignore:(ast.Str|Attribute s|ast.NameConstant|ast.Num) is deprecated:DeprecationWarning:_pytest", 30 | ] 31 | testpaths = ["tests"] 32 | 33 | [tool.cibuildwheel] 34 | test-command = "pytest {project}/tests" 35 | test-extras = ["test"] 36 | test-skip = ["*universal2:arm64"] 37 | # Setuptools bug causes collision between pypy and cpython artifacts 38 | before-build = "rm -rf {project}/build" 39 | 40 | [tool.ruff] 41 | target-version = "py37" 42 | 43 | [tool.ruff.lint] 44 | extend-select = [ 45 | "B", # flake8-bugbear 46 | "I", # isort 47 | "PGH", # pygrep-hooks 48 | "RUF", # Ruff-specific 49 | "UP", # pyupgrade 50 | ] 51 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # To use: 2 | # 3 | # pre-commit run -a 4 | # 5 | # Or: 6 | # 7 | # pre-commit install # (runs every time you commit in git) 8 | # 9 | # To update this file: 10 | # 11 | # pre-commit autoupdate 12 | # 13 | # See https://github.com/pre-commit/pre-commit 14 | 15 | ci: 16 | autoupdate_commit_msg: "chore: update pre-commit hooks" 17 | autofix_commit_msg: "style: pre-commit fixes" 18 | 19 | repos: 20 | # Standard hooks 21 | - repo: https://github.com/pre-commit/pre-commit-hooks 22 | rev: v4.6.0 23 | hooks: 24 | - id: check-added-large-files 25 | - id: check-case-conflict 26 | - id: check-merge-conflict 27 | - id: check-symlinks 28 | - id: check-yaml 29 | exclude: ^conda\.recipe/meta\.yaml$ 30 | - id: debug-statements 31 | - id: end-of-file-fixer 32 | - id: mixed-line-ending 33 | - id: requirements-txt-fixer 34 | - id: trailing-whitespace 35 | 36 | - repo: https://github.com/astral-sh/ruff-pre-commit 37 | rev: "v0.4.2" 38 | hooks: 39 | - id: ruff 40 | args: ["--fix", "--show-fixes"] 41 | - id: ruff-format 42 | exclude: ^(docs) 43 | 44 | # Checking static types 45 | - repo: https://github.com/pre-commit/mirrors-mypy 46 | rev: "v1.10.0" 47 | hooks: 48 | - id: mypy 49 | files: "setup.py" 50 | args: [] 51 | additional_dependencies: [types-setuptools] 52 | 53 | # Changes tabs to spaces 54 | - repo: https://github.com/Lucas-C/pre-commit-hooks 55 | rev: v1.5.5 56 | hooks: 57 | - id: remove-tabs 58 | exclude: ^(docs) 59 | 60 | # CMake formatting 61 | - repo: https://github.com/cheshirekow/cmake-format-precommit 62 | rev: v0.6.13 63 | hooks: 64 | - id: cmake-format 65 | additional_dependencies: [pyyaml] 66 | types: [file] 67 | files: (\.cmake|CMakeLists.txt)(.in)?$ 68 | 69 | # Suggested hook if you add a .clang-format file 70 | # - repo: https://github.com/pre-commit/mirrors-clang-format 71 | # rev: v13.0.0 72 | # hooks: 73 | # - id: clang-format 74 | -------------------------------------------------------------------------------- /.github/workflows/wheels.yml: -------------------------------------------------------------------------------- 1 | name: Wheels 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | push: 7 | branches: 8 | - master 9 | release: 10 | types: 11 | - published 12 | 13 | jobs: 14 | build_sdist: 15 | name: Build SDist 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v4 19 | with: 20 | submodules: true 21 | 22 | - name: Build SDist 23 | run: pipx run build --sdist 24 | 25 | - name: Check metadata 26 | run: pipx run twine check dist/* 27 | 28 | - uses: actions/upload-artifact@v4 29 | with: 30 | name: cibw-sdist 31 | path: dist/*.tar.gz 32 | 33 | 34 | build_wheels: 35 | name: Wheels on ${{ matrix.os }} 36 | runs-on: ${{ matrix.os }} 37 | strategy: 38 | fail-fast: false 39 | matrix: 40 | os: [ubuntu-latest, windows-latest, macos-13] 41 | 42 | steps: 43 | - uses: actions/checkout@v4 44 | with: 45 | submodules: true 46 | 47 | - uses: pypa/cibuildwheel@v2.17 48 | env: 49 | CIBW_ARCHS_MACOS: auto universal2 50 | 51 | - name: Verify clean directory 52 | run: git diff --exit-code 53 | shell: bash 54 | 55 | - name: Upload wheels 56 | uses: actions/upload-artifact@v4 57 | with: 58 | name: cibw-wheels-${{ matrix.os }} 59 | path: wheelhouse/*.whl 60 | 61 | 62 | upload_all: 63 | name: Upload if release 64 | needs: [build_wheels, build_sdist] 65 | runs-on: ubuntu-latest 66 | if: github.event_name == 'release' && github.event.action == 'published' 67 | 68 | steps: 69 | - uses: actions/setup-python@v5 70 | with: 71 | python-version: "3.x" 72 | 73 | - uses: actions/download-artifact@v4 74 | with: 75 | pattern: cibw-* 76 | path: dist 77 | merge-multiple: true 78 | 79 | - uses: pypa/gh-action-pypi-publish@release/v1 80 | with: 81 | password: ${{ secrets.pypi_password }} 82 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 The Pybind Development Team, All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | You are under no obligation whatsoever to provide any bug fixes, patches, or 29 | upgrades to the features, functionality or performance of the source code 30 | ("Enhancements") to anyone; however, if you choose to make your Enhancements 31 | available either publicly, or directly to the author of this software, without 32 | imposing a separate written license agreement for such Enhancements, then you 33 | hereby grant the following license: a non-exclusive, royalty-free perpetual 34 | license to install, use, modify, prepare derivative works, incorporate into 35 | other computer software, distribute, and sublicense such enhancements or 36 | derivative works thereof, in binary and source code form. 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cmake_example for pybind11 2 | 3 | [![Gitter][gitter-badge]][gitter-link] 4 | 5 | | CI | status | 6 | |----------------------|--------| 7 | | MSVC 2019 | [![AppVeyor][appveyor-badge]][appveyor-link] | 8 | | conda.recipe | [![Conda Actions Status][actions-conda-badge]][actions-conda-link] | 9 | | pip builds | [![Pip Actions Status][actions-pip-badge]][actions-pip-link] | 10 | | [`cibuildwheel`][] | [![Wheels Actions Status][actions-wheels-badge]][actions-wheels-link] | 11 | 12 | [gitter-badge]: https://badges.gitter.im/pybind/Lobby.svg 13 | [gitter-link]: https://gitter.im/pybind/Lobby 14 | [actions-badge]: https://github.com/pybind/cmake_example/workflows/Tests/badge.svg 15 | [actions-conda-link]: https://github.com/pybind/cmake_example/actions?query=workflow%3A%22Conda 16 | [actions-conda-badge]: https://github.com/pybind/cmake_example/workflows/Conda/badge.svg 17 | [actions-pip-link]: https://github.com/pybind/cmake_example/actions?query=workflow%3A%22Pip 18 | [actions-pip-badge]: https://github.com/pybind/cmake_example/workflows/Pip/badge.svg 19 | [actions-wheels-link]: https://github.com/pybind/cmake_example/actions?query=workflow%3AWheels 20 | [actions-wheels-badge]: https://github.com/pybind/cmake_example/workflows/Wheels/badge.svg 21 | [appveyor-link]: https://ci.appveyor.com/project/dean0x7d/cmake-example/branch/master 22 | [appveyor-badge]: https://ci.appveyor.com/api/projects/status/57nnxfm4subeug43/branch/master?svg=true 23 | 24 | An example [pybind11](https://github.com/pybind/pybind11) module built with a 25 | CMake-based build system. This is useful for C++ codebases that have an 26 | existing CMake project structure. This is being replaced by 27 | [`scikit_build_example`](https://github.com/pybind/scikit_build_example), which uses 28 | [scikit-build-core][], which is designed to allow Python 29 | packages to be driven from CMake without depending on setuptools. The approach here has 30 | some trade-offs not present in a pure setuptools build (see 31 | [`python_example`](https://github.com/pybind/python_example)) or scikit-build-core. Python 3.7+ required; 32 | see the commit history for older versions of Python. 33 | 34 | Problems vs. scikit-build-core based example: 35 | 36 | - You have to manually copy fixes/additions when they get added to this example (like when Apple Silicon support was added) 37 | - Modern editable installs are not supported (scikit-build-core doesn't support them either yet, but probably will soon) 38 | - You are depending on setuptools, which can and will change 39 | - 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) 40 | - You are stuck with whatever CMake ships with (scikit-build-core backports FindPython for you) 41 | 42 | 43 | ## Prerequisites 44 | 45 | * A compiler with C++11 support 46 | * Pip 10+ or CMake >= 3.4 (or 3.14+ on Windows, which was the first version to support VS 2019) 47 | * Ninja or Pip 10+ 48 | 49 | 50 | ## Installation 51 | 52 | Just clone this repository and pip install. Note the `--recursive` option which is 53 | needed for the pybind11 submodule: 54 | 55 | ```bash 56 | git clone --recursive https://github.com/pybind/cmake_example.git 57 | pip install ./cmake_example 58 | ``` 59 | 60 | With the `setup.py` file included in this example, the `pip install` command will 61 | invoke CMake and build the pybind11 module as specified in `CMakeLists.txt`. 62 | 63 | 64 | 65 | ## Building the documentation 66 | 67 | Documentation for the example project is generated using Sphinx. Sphinx has the 68 | ability to automatically inspect the signatures and documentation strings in 69 | the extension module to generate beautiful documentation in a variety formats. 70 | The following command generates HTML-based reference documentation; for other 71 | formats please refer to the Sphinx manual: 72 | 73 | - `cd cmake_example/docs` 74 | - `make html` 75 | 76 | 77 | ## License 78 | 79 | Pybind11 is provided under a BSD-style license that can be found in the LICENSE 80 | file. By using, distributing, or contributing to this project, you agree to the 81 | terms and conditions of this license. 82 | 83 | 84 | ## Test call 85 | 86 | ```python 87 | import cmake_example 88 | cmake_example.add(1, 2) 89 | ``` 90 | 91 | [`cibuildwheel`]: https://cibuildwheel.readthedocs.io 92 | [scikit-build-core]: https://github.com/scikit-build/scikit-build-core 93 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | import subprocess 4 | import sys 5 | from pathlib import Path 6 | 7 | from setuptools import Extension, setup 8 | from setuptools.command.build_ext import build_ext 9 | 10 | # Convert distutils Windows platform specifiers to CMake -A arguments 11 | PLAT_TO_CMAKE = { 12 | "win32": "Win32", 13 | "win-amd64": "x64", 14 | "win-arm32": "ARM", 15 | "win-arm64": "ARM64", 16 | } 17 | 18 | 19 | # A CMakeExtension needs a sourcedir instead of a file list. 20 | # The name must be the _single_ output extension from the CMake build. 21 | # If you need multiple extensions, see scikit-build. 22 | class CMakeExtension(Extension): 23 | def __init__(self, name: str, sourcedir: str = "") -> None: 24 | super().__init__(name, sources=[]) 25 | self.sourcedir = os.fspath(Path(sourcedir).resolve()) 26 | 27 | 28 | class CMakeBuild(build_ext): 29 | def build_extension(self, ext: CMakeExtension) -> None: 30 | # Must be in this form due to bug in .resolve() only fixed in Python 3.10+ 31 | ext_fullpath = Path.cwd() / self.get_ext_fullpath(ext.name) 32 | extdir = ext_fullpath.parent.resolve() 33 | 34 | # Using this requires trailing slash for auto-detection & inclusion of 35 | # auxiliary "native" libs 36 | 37 | debug = int(os.environ.get("DEBUG", 0)) if self.debug is None else self.debug 38 | cfg = "Debug" if debug else "Release" 39 | 40 | # CMake lets you override the generator - we need to check this. 41 | # Can be set with Conda-Build, for example. 42 | cmake_generator = os.environ.get("CMAKE_GENERATOR", "") 43 | 44 | # Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON 45 | # EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code 46 | # from Python. 47 | cmake_args = [ 48 | f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}", 49 | f"-DPYTHON_EXECUTABLE={sys.executable}", 50 | f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm 51 | ] 52 | build_args = [] 53 | # Adding CMake arguments set as environment variable 54 | # (needed e.g. to build for ARM OSx on conda-forge) 55 | if "CMAKE_ARGS" in os.environ: 56 | cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") if item] 57 | 58 | # In this example, we pass in the version to C++. You might not need to. 59 | cmake_args += [f"-DEXAMPLE_VERSION_INFO={self.distribution.get_version()}"] 60 | 61 | if self.compiler.compiler_type != "msvc": 62 | # Using Ninja-build since it a) is available as a wheel and b) 63 | # multithreads automatically. MSVC would require all variables be 64 | # exported for Ninja to pick it up, which is a little tricky to do. 65 | # Users can override the generator with CMAKE_GENERATOR in CMake 66 | # 3.15+. 67 | if not cmake_generator or cmake_generator == "Ninja": 68 | try: 69 | import ninja 70 | 71 | ninja_executable_path = Path(ninja.BIN_DIR) / "ninja" 72 | cmake_args += [ 73 | "-GNinja", 74 | f"-DCMAKE_MAKE_PROGRAM:FILEPATH={ninja_executable_path}", 75 | ] 76 | except ImportError: 77 | pass 78 | 79 | else: 80 | # Single config generators are handled "normally" 81 | single_config = any(x in cmake_generator for x in {"NMake", "Ninja"}) 82 | 83 | # CMake allows an arch-in-generator style for backward compatibility 84 | contains_arch = any(x in cmake_generator for x in {"ARM", "Win64"}) 85 | 86 | # Specify the arch if using MSVC generator, but only if it doesn't 87 | # contain a backward-compatibility arch spec already in the 88 | # generator name. 89 | if not single_config and not contains_arch: 90 | cmake_args += ["-A", PLAT_TO_CMAKE[self.plat_name]] 91 | 92 | # Multi-config generators have a different way to specify configs 93 | if not single_config: 94 | cmake_args += [ 95 | f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}" 96 | ] 97 | build_args += ["--config", cfg] 98 | 99 | if sys.platform.startswith("darwin"): 100 | # Cross-compile support for macOS - respect ARCHFLAGS if set 101 | archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", "")) 102 | if archs: 103 | cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))] 104 | 105 | # Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level 106 | # across all generators. 107 | if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ: 108 | # self.parallel is a Python 3 only way to set parallel jobs by hand 109 | # using -j in the build_ext call, not supported by pip or PyPA-build. 110 | if hasattr(self, "parallel") and self.parallel: 111 | # CMake 3.12+ only. 112 | build_args += [f"-j{self.parallel}"] 113 | 114 | build_temp = Path(self.build_temp) / ext.name 115 | if not build_temp.exists(): 116 | build_temp.mkdir(parents=True) 117 | 118 | subprocess.run( 119 | ["cmake", ext.sourcedir, *cmake_args], cwd=build_temp, check=True 120 | ) 121 | subprocess.run( 122 | ["cmake", "--build", ".", *build_args], cwd=build_temp, check=True 123 | ) 124 | 125 | 126 | # The information here can also be placed in setup.cfg - better separation of 127 | # logic and declaration, and simpler if you include description/version in a file. 128 | setup( 129 | name="cmake_example", 130 | version="0.0.1", 131 | author="Dean Moldovan", 132 | author_email="dean0x7d@gmail.com", 133 | description="A test project using pybind11 and CMake", 134 | long_description="", 135 | ext_modules=[CMakeExtension("cmake_example")], 136 | cmdclass={"build_ext": CMakeBuild}, 137 | zip_safe=False, 138 | extras_require={"test": ["pytest>=6.0"]}, 139 | python_requires=">=3.7", 140 | ) 141 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help 23 | help: 24 | @echo "Please use \`make ' where is one of" 25 | @echo " html to make standalone HTML files" 26 | @echo " dirhtml to make HTML files named index.html in directories" 27 | @echo " singlehtml to make a single large HTML file" 28 | @echo " pickle to make pickle files" 29 | @echo " json to make JSON files" 30 | @echo " htmlhelp to make HTML files and a HTML help project" 31 | @echo " qthelp to make HTML files and a qthelp project" 32 | @echo " applehelp to make an Apple Help Book" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | @echo " coverage to run coverage check of the documentation (if enabled)" 49 | 50 | .PHONY: clean 51 | clean: 52 | rm -rf $(BUILDDIR)/* 53 | 54 | .PHONY: html 55 | html: 56 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 57 | @echo 58 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 59 | 60 | .PHONY: dirhtml 61 | dirhtml: 62 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 63 | @echo 64 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 65 | 66 | .PHONY: singlehtml 67 | singlehtml: 68 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 69 | @echo 70 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 71 | 72 | .PHONY: pickle 73 | pickle: 74 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 75 | @echo 76 | @echo "Build finished; now you can process the pickle files." 77 | 78 | .PHONY: json 79 | json: 80 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 81 | @echo 82 | @echo "Build finished; now you can process the JSON files." 83 | 84 | .PHONY: htmlhelp 85 | htmlhelp: 86 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 87 | @echo 88 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 89 | ".hhp project file in $(BUILDDIR)/htmlhelp." 90 | 91 | .PHONY: qthelp 92 | qthelp: 93 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 94 | @echo 95 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 96 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 97 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/cmake_example.qhcp" 98 | @echo "To view the help file:" 99 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/cmake_example.qhc" 100 | 101 | .PHONY: applehelp 102 | applehelp: 103 | $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp 104 | @echo 105 | @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." 106 | @echo "N.B. You won't be able to view it unless you put it in" \ 107 | "~/Library/Documentation/Help or install it in your application" \ 108 | "bundle." 109 | 110 | .PHONY: devhelp 111 | devhelp: 112 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 113 | @echo 114 | @echo "Build finished." 115 | @echo "To view the help file:" 116 | @echo "# mkdir -p $$HOME/.local/share/devhelp/cmake_example" 117 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/cmake_example" 118 | @echo "# devhelp" 119 | 120 | .PHONY: epub 121 | epub: 122 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 123 | @echo 124 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 125 | 126 | .PHONY: latex 127 | latex: 128 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 129 | @echo 130 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 131 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 132 | "(use \`make latexpdf' here to do that automatically)." 133 | 134 | .PHONY: latexpdf 135 | latexpdf: 136 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 137 | @echo "Running LaTeX files through pdflatex..." 138 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 139 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 140 | 141 | .PHONY: latexpdfja 142 | latexpdfja: 143 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 144 | @echo "Running LaTeX files through platex and dvipdfmx..." 145 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 146 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 147 | 148 | .PHONY: text 149 | text: 150 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 151 | @echo 152 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 153 | 154 | .PHONY: man 155 | man: 156 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 157 | @echo 158 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 159 | 160 | .PHONY: texinfo 161 | texinfo: 162 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 163 | @echo 164 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 165 | @echo "Run \`make' in that directory to run these through makeinfo" \ 166 | "(use \`make info' here to do that automatically)." 167 | 168 | .PHONY: info 169 | info: 170 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 171 | @echo "Running Texinfo files through makeinfo..." 172 | make -C $(BUILDDIR)/texinfo info 173 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 174 | 175 | .PHONY: gettext 176 | gettext: 177 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 178 | @echo 179 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 180 | 181 | .PHONY: changes 182 | changes: 183 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 184 | @echo 185 | @echo "The overview file is in $(BUILDDIR)/changes." 186 | 187 | .PHONY: linkcheck 188 | linkcheck: 189 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 190 | @echo 191 | @echo "Link check complete; look for any errors in the above output " \ 192 | "or in $(BUILDDIR)/linkcheck/output.txt." 193 | 194 | .PHONY: doctest 195 | doctest: 196 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 197 | @echo "Testing of doctests in the sources finished, look at the " \ 198 | "results in $(BUILDDIR)/doctest/output.txt." 199 | 200 | .PHONY: coverage 201 | coverage: 202 | $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage 203 | @echo "Testing of coverage in the sources finished, look at the " \ 204 | "results in $(BUILDDIR)/coverage/python.txt." 205 | 206 | .PHONY: xml 207 | xml: 208 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 209 | @echo 210 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 211 | 212 | .PHONY: pseudoxml 213 | pseudoxml: 214 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 215 | @echo 216 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 217 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | echo. coverage to run coverage check of the documentation if enabled 41 | goto end 42 | ) 43 | 44 | if "%1" == "clean" ( 45 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 46 | del /q /s %BUILDDIR%\* 47 | goto end 48 | ) 49 | 50 | 51 | REM Check if sphinx-build is available and fallback to Python version if any 52 | %SPHINXBUILD% 1>NUL 2>NUL 53 | if errorlevel 9009 goto sphinx_python 54 | goto sphinx_ok 55 | 56 | :sphinx_python 57 | 58 | set SPHINXBUILD=python -m sphinx.__init__ 59 | %SPHINXBUILD% 2> nul 60 | if errorlevel 9009 ( 61 | echo. 62 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 63 | echo.installed, then set the SPHINXBUILD environment variable to point 64 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 65 | echo.may add the Sphinx directory to PATH. 66 | echo. 67 | echo.If you don't have Sphinx installed, grab it from 68 | echo.http://sphinx-doc.org/ 69 | exit /b 1 70 | ) 71 | 72 | :sphinx_ok 73 | 74 | 75 | if "%1" == "html" ( 76 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 77 | if errorlevel 1 exit /b 1 78 | echo. 79 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 80 | goto end 81 | ) 82 | 83 | if "%1" == "dirhtml" ( 84 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 85 | if errorlevel 1 exit /b 1 86 | echo. 87 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 88 | goto end 89 | ) 90 | 91 | if "%1" == "singlehtml" ( 92 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 93 | if errorlevel 1 exit /b 1 94 | echo. 95 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 96 | goto end 97 | ) 98 | 99 | if "%1" == "pickle" ( 100 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 101 | if errorlevel 1 exit /b 1 102 | echo. 103 | echo.Build finished; now you can process the pickle files. 104 | goto end 105 | ) 106 | 107 | if "%1" == "json" ( 108 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 109 | if errorlevel 1 exit /b 1 110 | echo. 111 | echo.Build finished; now you can process the JSON files. 112 | goto end 113 | ) 114 | 115 | if "%1" == "htmlhelp" ( 116 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 117 | if errorlevel 1 exit /b 1 118 | echo. 119 | echo.Build finished; now you can run HTML Help Workshop with the ^ 120 | .hhp project file in %BUILDDIR%/htmlhelp. 121 | goto end 122 | ) 123 | 124 | if "%1" == "qthelp" ( 125 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 129 | .qhcp project file in %BUILDDIR%/qthelp, like this: 130 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\cmake_example.qhcp 131 | echo.To view the help file: 132 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\cmake_example.ghc 133 | goto end 134 | ) 135 | 136 | if "%1" == "devhelp" ( 137 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 138 | if errorlevel 1 exit /b 1 139 | echo. 140 | echo.Build finished. 141 | goto end 142 | ) 143 | 144 | if "%1" == "epub" ( 145 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 146 | if errorlevel 1 exit /b 1 147 | echo. 148 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 149 | goto end 150 | ) 151 | 152 | if "%1" == "latex" ( 153 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 154 | if errorlevel 1 exit /b 1 155 | echo. 156 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 157 | goto end 158 | ) 159 | 160 | if "%1" == "latexpdf" ( 161 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 162 | cd %BUILDDIR%/latex 163 | make all-pdf 164 | cd %~dp0 165 | echo. 166 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 167 | goto end 168 | ) 169 | 170 | if "%1" == "latexpdfja" ( 171 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 172 | cd %BUILDDIR%/latex 173 | make all-pdf-ja 174 | cd %~dp0 175 | echo. 176 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 177 | goto end 178 | ) 179 | 180 | if "%1" == "text" ( 181 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 182 | if errorlevel 1 exit /b 1 183 | echo. 184 | echo.Build finished. The text files are in %BUILDDIR%/text. 185 | goto end 186 | ) 187 | 188 | if "%1" == "man" ( 189 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 190 | if errorlevel 1 exit /b 1 191 | echo. 192 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 193 | goto end 194 | ) 195 | 196 | if "%1" == "texinfo" ( 197 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 198 | if errorlevel 1 exit /b 1 199 | echo. 200 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 201 | goto end 202 | ) 203 | 204 | if "%1" == "gettext" ( 205 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 206 | if errorlevel 1 exit /b 1 207 | echo. 208 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 209 | goto end 210 | ) 211 | 212 | if "%1" == "changes" ( 213 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 214 | if errorlevel 1 exit /b 1 215 | echo. 216 | echo.The overview file is in %BUILDDIR%/changes. 217 | goto end 218 | ) 219 | 220 | if "%1" == "linkcheck" ( 221 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 222 | if errorlevel 1 exit /b 1 223 | echo. 224 | echo.Link check complete; look for any errors in the above output ^ 225 | or in %BUILDDIR%/linkcheck/output.txt. 226 | goto end 227 | ) 228 | 229 | if "%1" == "doctest" ( 230 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 231 | if errorlevel 1 exit /b 1 232 | echo. 233 | echo.Testing of doctests in the sources finished, look at the ^ 234 | results in %BUILDDIR%/doctest/output.txt. 235 | goto end 236 | ) 237 | 238 | if "%1" == "coverage" ( 239 | %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage 240 | if errorlevel 1 exit /b 1 241 | echo. 242 | echo.Testing of coverage in the sources finished, look at the ^ 243 | results in %BUILDDIR%/coverage/python.txt. 244 | goto end 245 | ) 246 | 247 | if "%1" == "xml" ( 248 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 249 | if errorlevel 1 exit /b 1 250 | echo. 251 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 252 | goto end 253 | ) 254 | 255 | if "%1" == "pseudoxml" ( 256 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 257 | if errorlevel 1 exit /b 1 258 | echo. 259 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 260 | goto end 261 | ) 262 | 263 | :end 264 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # 2 | # python_exameple documentation build configuration file, created by 3 | # sphinx-quickstart on Fri Feb 26 00:29:33 2016. 4 | # 5 | # This file is execfile()d with the current directory set to its 6 | # containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | 15 | # If extensions (or modules to document with autodoc) are in another directory, 16 | # add these directories to sys.path here. If the directory is relative to the 17 | # documentation root, use os.path.abspath to make it absolute, like shown here. 18 | #sys.path.insert(0, os.path.abspath('.')) 19 | 20 | # -- General configuration ------------------------------------------------ 21 | 22 | # If your documentation needs a minimal Sphinx version, state it here. 23 | #needs_sphinx = '1.0' 24 | 25 | # Add any Sphinx extension module names here, as strings. They can be 26 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 27 | # ones. 28 | extensions = [ 29 | 'sphinx.ext.autodoc', 30 | 'sphinx.ext.intersphinx', 31 | 'sphinx.ext.autosummary', 32 | 'sphinx.ext.napoleon', 33 | ] 34 | 35 | autosummary_generate = True 36 | 37 | # Add any paths that contain templates here, relative to this directory. 38 | templates_path = ['_templates'] 39 | 40 | # The suffix(es) of source filenames. 41 | # You can specify multiple suffix as a list of string: 42 | # source_suffix = ['.rst', '.md'] 43 | source_suffix = '.rst' 44 | 45 | # The encoding of source files. 46 | #source_encoding = 'utf-8-sig' 47 | 48 | # The master toctree document. 49 | master_doc = 'index' 50 | 51 | # General information about the project. 52 | project = 'cmake_example' 53 | copyright = '2016, Sylvain Corlay' 54 | author = 'Sylvain Corlay' 55 | 56 | # The version info for the project you're documenting, acts as replacement for 57 | # |version| and |release|, also used in various other places throughout the 58 | # built documents. 59 | # 60 | # The short X.Y version. 61 | version = '0.0.1' 62 | # The full version, including alpha/beta/rc tags. 63 | release = '0.0.1' 64 | 65 | # The language for content autogenerated by Sphinx. Refer to documentation 66 | # for a list of supported languages. 67 | # 68 | # This is also used if you do content translation via gettext catalogs. 69 | # Usually you set "language" from the command line for these cases. 70 | language = None 71 | 72 | # There are two options for replacing |today|: either, you set today to some 73 | # non-false value, then it is used: 74 | #today = '' 75 | # Else, today_fmt is used as the format for a strftime call. 76 | #today_fmt = '%B %d, %Y' 77 | 78 | # List of patterns, relative to source directory, that match files and 79 | # directories to ignore when looking for source files. 80 | exclude_patterns = ['_build'] 81 | 82 | # The reST default role (used for this markup: `text`) to use for all 83 | # documents. 84 | #default_role = None 85 | 86 | # If true, '()' will be appended to :func: etc. cross-reference text. 87 | #add_function_parentheses = True 88 | 89 | # If true, the current module name will be prepended to all description 90 | # unit titles (such as .. function::). 91 | #add_module_names = True 92 | 93 | # If true, sectionauthor and moduleauthor directives will be shown in the 94 | # output. They are ignored by default. 95 | #show_authors = False 96 | 97 | # The name of the Pygments (syntax highlighting) style to use. 98 | pygments_style = 'sphinx' 99 | 100 | # A list of ignored prefixes for module index sorting. 101 | #modindex_common_prefix = [] 102 | 103 | # If true, keep warnings as "system message" paragraphs in the built documents. 104 | #keep_warnings = False 105 | 106 | # If true, `todo` and `todoList` produce output, else they produce nothing. 107 | todo_include_todos = False 108 | 109 | 110 | # -- Options for HTML output ---------------------------------------------- 111 | 112 | # The theme to use for HTML and HTML Help pages. See the documentation for 113 | # a list of builtin themes. 114 | html_theme = 'alabaster' 115 | 116 | # Theme options are theme-specific and customize the look and feel of a theme 117 | # further. For a list of options available for each theme, see the 118 | # documentation. 119 | #html_theme_options = {} 120 | 121 | # Add any paths that contain custom themes here, relative to this directory. 122 | #html_theme_path = [] 123 | 124 | # The name for this set of Sphinx documents. If None, it defaults to 125 | # " v documentation". 126 | #html_title = None 127 | 128 | # A shorter title for the navigation bar. Default is the same as html_title. 129 | #html_short_title = None 130 | 131 | # The name of an image file (relative to this directory) to place at the top 132 | # of the sidebar. 133 | #html_logo = None 134 | 135 | # The name of an image file (within the static path) to use as favicon of the 136 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 137 | # pixels large. 138 | #html_favicon = None 139 | 140 | # Add any paths that contain custom static files (such as style sheets) here, 141 | # relative to this directory. They are copied after the builtin static files, 142 | # so a file named "default.css" will overwrite the builtin "default.css". 143 | html_static_path = ['_static'] 144 | 145 | # Add any extra paths that contain custom files (such as robots.txt or 146 | # .htaccess) here, relative to this directory. These files are copied 147 | # directly to the root of the documentation. 148 | #html_extra_path = [] 149 | 150 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 151 | # using the given strftime format. 152 | #html_last_updated_fmt = '%b %d, %Y' 153 | 154 | # If true, SmartyPants will be used to convert quotes and dashes to 155 | # typographically correct entities. 156 | #html_use_smartypants = True 157 | 158 | # Custom sidebar templates, maps document names to template names. 159 | #html_sidebars = {} 160 | 161 | # Additional templates that should be rendered to pages, maps page names to 162 | # template names. 163 | #html_additional_pages = {} 164 | 165 | # If false, no module index is generated. 166 | #html_domain_indices = True 167 | 168 | # If false, no index is generated. 169 | #html_use_index = True 170 | 171 | # If true, the index is split into individual pages for each letter. 172 | #html_split_index = False 173 | 174 | # If true, links to the reST sources are added to the pages. 175 | #html_show_sourcelink = True 176 | 177 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 178 | #html_show_sphinx = True 179 | 180 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 181 | #html_show_copyright = True 182 | 183 | # If true, an OpenSearch description file will be output, and all pages will 184 | # contain a tag referring to it. The value of this option must be the 185 | # base URL from which the finished HTML is served. 186 | #html_use_opensearch = '' 187 | 188 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 189 | #html_file_suffix = None 190 | 191 | # Language to be used for generating the HTML full-text search index. 192 | # Sphinx supports the following languages: 193 | # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' 194 | # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' 195 | #html_search_language = 'en' 196 | 197 | # A dictionary with options for the search language support, empty by default. 198 | # Now only 'ja' uses this config value 199 | #html_search_options = {'type': 'default'} 200 | 201 | # The name of a javascript file (relative to the configuration directory) that 202 | # implements a search results scorer. If empty, the default will be used. 203 | #html_search_scorer = 'scorer.js' 204 | 205 | # Output file base name for HTML help builder. 206 | htmlhelp_basename = 'cmake_exampledoc' 207 | 208 | # -- Options for LaTeX output --------------------------------------------- 209 | 210 | latex_elements = { 211 | # The paper size ('letterpaper' or 'a4paper'). 212 | #'papersize': 'letterpaper', 213 | 214 | # The font size ('10pt', '11pt' or '12pt'). 215 | #'pointsize': '10pt', 216 | 217 | # Additional stuff for the LaTeX preamble. 218 | #'preamble': '', 219 | 220 | # Latex figure (float) alignment 221 | #'figure_align': 'htbp', 222 | } 223 | 224 | # Grouping the document tree into LaTeX files. List of tuples 225 | # (source start file, target name, title, 226 | # author, documentclass [howto, manual, or own class]). 227 | latex_documents = [ 228 | (master_doc, 'cmake_example.tex', 'cmake_example Documentation', 229 | 'Sylvain Corlay', 'manual'), 230 | ] 231 | 232 | # The name of an image file (relative to this directory) to place at the top of 233 | # the title page. 234 | #latex_logo = None 235 | 236 | # For "manual" documents, if this is true, then toplevel headings are parts, 237 | # not chapters. 238 | #latex_use_parts = False 239 | 240 | # If true, show page references after internal links. 241 | #latex_show_pagerefs = False 242 | 243 | # If true, show URL addresses after external links. 244 | #latex_show_urls = False 245 | 246 | # Documents to append as an appendix to all manuals. 247 | #latex_appendices = [] 248 | 249 | # If false, no module index is generated. 250 | #latex_domain_indices = True 251 | 252 | 253 | # -- Options for manual page output --------------------------------------- 254 | 255 | # One entry per manual page. List of tuples 256 | # (source start file, name, description, authors, manual section). 257 | man_pages = [ 258 | (master_doc, 'cmake_example', 'cmake_example Documentation', 259 | [author], 1) 260 | ] 261 | 262 | # If true, show URL addresses after external links. 263 | #man_show_urls = False 264 | 265 | 266 | # -- Options for Texinfo output ------------------------------------------- 267 | 268 | # Grouping the document tree into Texinfo files. List of tuples 269 | # (source start file, target name, title, author, 270 | # dir menu entry, description, category) 271 | texinfo_documents = [ 272 | (master_doc, 'cmake_example', 'cmake_example Documentation', 273 | author, 'cmake_example', 'One line description of project.', 274 | 'Miscellaneous'), 275 | ] 276 | 277 | # Documents to append as an appendix to all manuals. 278 | #texinfo_appendices = [] 279 | 280 | # If false, no module index is generated. 281 | #texinfo_domain_indices = True 282 | 283 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 284 | #texinfo_show_urls = 'footnote' 285 | 286 | # If true, do not generate a @detailmenu in the "Top" node's menu. 287 | #texinfo_no_detailmenu = False 288 | 289 | 290 | # Example configuration for intersphinx: refer to the Python standard library. 291 | intersphinx_mapping = {'https://docs.python.org/': None} 292 | --------------------------------------------------------------------------------