generated from pybind/cmake_example
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
339d370
commit 8e85441
Showing
34 changed files
with
2,039 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
BasedOnStyle: LLVM | ||
AlignAfterOpenBracket: 'Align' | ||
IndentPPDirectives: AfterHash | ||
ColumnLimit: 120 | ||
PointerAlignment: Left | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ updates: | |
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
interval: "monthly" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,15 @@ on: | |
pull_request: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
|
||
jobs: | ||
pre-commit: | ||
name: Format | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
- uses: actions/checkout@v4.1.1 | ||
- uses: actions/setup-python@v5.0.0 | ||
with: | ||
python-version: "3.x" | ||
- uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ on: | |
pull_request: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
release: | ||
types: | ||
- published | ||
|
@@ -36,7 +36,7 @@ jobs: | |
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
os: [ubuntu-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
@@ -46,6 +46,8 @@ jobs: | |
- uses: pypa/[email protected] | ||
env: | ||
CIBW_ARCHS_MACOS: auto universal2 | ||
CIBW_SKIP: cp36-* cp37-* cp38-* | ||
|
||
|
||
- name: Verify clean directory | ||
run: git diff --exit-code | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ _generate/ | |
*.py[cod] | ||
*.egg-info | ||
*env* | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
path = pybind11 | ||
url = https://github.com/pybind/pybind11.git | ||
branch = master | ||
[submodule "include/compc"] | ||
path = include/compc | ||
url = [email protected]:JeffWigger/compintc.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
cmake_minimum_required(VERSION 3.4...3.18) | ||
project(cmake_example) | ||
project(compintpy) | ||
|
||
add_subdirectory(include/compc compintc) | ||
target_compile_options(compintc PRIVATE -fPIC) | ||
|
||
add_subdirectory(pybind11) | ||
pybind11_add_module(cmake_example src/main.cpp) | ||
pybind11_add_module(_compintpy src/main.cpp) | ||
|
||
target_link_libraries(_compintpy PRIVATE compintc) | ||
|
||
# EXAMPLE_VERSION_INFO is defined by setup.py and passed into the C++ code as a | ||
# define (VERSION_INFO) here. | ||
target_compile_definitions(cmake_example | ||
PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO}) | ||
target_compile_definitions(_compintpy | ||
PRIVATE VERSION_INFO=${compintpy_VERSION_INFO}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
include README.md LICENSE pybind11/LICENSE | ||
graft pybind11/include | ||
graft pybind11/tools | ||
graft compintpy | ||
graft include/compc | ||
graft src | ||
global-include CMakeLists.txt *.cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,7 @@ | ||
# cmake_example for pybind11 | ||
Install the project with | ||
|
||
[![Gitter][gitter-badge]][gitter-link] | ||
|
||
| CI | status | | ||
|----------------------|--------| | ||
| MSVC 2019 | [![AppVeyor][appveyor-badge]][appveyor-link] | | ||
| conda.recipe | [![Conda Actions Status][actions-conda-badge]][actions-conda-link] | | ||
| pip builds | [![Pip Actions Status][actions-pip-badge]][actions-pip-link] | | ||
| [`cibuildwheel`][] | [![Wheels Actions Status][actions-wheels-badge]][actions-wheels-link] | | ||
|
||
[gitter-badge]: https://badges.gitter.im/pybind/Lobby.svg | ||
[gitter-link]: https://gitter.im/pybind/Lobby | ||
[actions-badge]: https://github.com/pybind/cmake_example/workflows/Tests/badge.svg | ||
[actions-conda-link]: https://github.com/pybind/cmake_example/actions?query=workflow%3A%22Conda | ||
[actions-conda-badge]: https://github.com/pybind/cmake_example/workflows/Conda/badge.svg | ||
[actions-pip-link]: https://github.com/pybind/cmake_example/actions?query=workflow%3A%22Pip | ||
[actions-pip-badge]: https://github.com/pybind/cmake_example/workflows/Pip/badge.svg | ||
[actions-wheels-link]: https://github.com/pybind/cmake_example/actions?query=workflow%3AWheels | ||
[actions-wheels-badge]: https://github.com/pybind/cmake_example/workflows/Wheels/badge.svg | ||
[appveyor-link]: https://ci.appveyor.com/project/dean0x7d/cmake-example/branch/master | ||
[appveyor-badge]: https://ci.appveyor.com/api/projects/status/57nnxfm4subeug43/branch/master?svg=true | ||
|
||
An example [pybind11](https://github.com/pybind/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`](https://github.com/pybind/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`](https://github.com/pybind/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: | ||
|
||
```bash | ||
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 | ||
|
||
```python | ||
import cmake_example | ||
cmake_example.add(1, 2) | ||
git clone --recursive https://github.com/JeffWigger/compintpy.git | ||
cd compintpy | ||
pip install . | ||
``` | ||
|
||
[`cibuildwheel`]: https://cibuildwheel.readthedocs.io | ||
[scikit-build-core]: https://github.com/scikit-build/scikit-build-core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# no import rewrittes |
Oops, something went wrong.