Skip to content

Commit

Permalink
add files for release
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffWigger committed Jan 8, 2024
1 parent 339d370 commit 8e85441
Show file tree
Hide file tree
Showing 34 changed files with 2,039 additions and 348 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ build_script:
- ps: |
python -m build -s
cd dist
python -m pip install --verbose cmake_example-0.0.1.tar.gz
python -m pip install --verbose compintpy-0.0.1.tar.gz
cd ..
test_script:
- ps: python -m pytest
7 changes: 7 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
BasedOnStyle: LLVM
AlignAfterOpenBracket: 'Align'
IndentPPDirectives: AfterHash
ColumnLimit: 120
PointerAlignment: Left
...
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "monthly"
48 changes: 0 additions & 48 deletions .github/workflows/conda.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
6 changes: 3 additions & 3 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ on:
pull_request:
push:
branches:
- master
- main

jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [windows-latest, macos-latest, ubuntu-latest]
python-version: ["3.7", "3.11"]
platform: [ubuntu-latest]
python-version: ["3.9", "3.11"]

runs-on: ${{ matrix.platform }}

Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
push:
branches:
- master
- main
release:
types:
- published
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ _generate/
*.py[cod]
*.egg-info
*env*
.vscode/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 10 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ci:
repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -33,22 +33,16 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace

# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
exclude: ^(docs)

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.261"
rev: "v0.1.11"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

# Checking static types
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.2.0"
rev: "v1.8.0"
hooks:
- id: mypy
files: "setup.py"
Expand All @@ -57,7 +51,7 @@ repos:

# Changes tabs to spaces
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.1
rev: v1.5.4
hooks:
- id: remove-tabs
exclude: ^(docs)
Expand All @@ -71,8 +65,8 @@ repos:
types: [file]
files: (\.cmake|CMakeLists.txt)(.in)?$

# Suggested hook if you add a .clang-format file
# - repo: https://github.com/pre-commit/mirrors-clang-format
# rev: v13.0.0
# hooks:
# - id: clang-format
- repo: https://github.com/cpp-linter/cpp-linter-hooks
rev: v0.2.5
hooks:
- id: clang-format
args: ["src/main.cpp", "--style=file"]
15 changes: 9 additions & 6 deletions CMakeLists.txt
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})
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2016 The Pybind Development Team, All rights reserved.
Copyright (c) 2023 Jeffrey Wigger, All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
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
93 changes: 4 additions & 89 deletions README.md
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
1 change: 1 addition & 0 deletions compintpy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# no import rewrittes
Loading

0 comments on commit 8e85441

Please sign in to comment.