Skip to content

Commit f5eb8e1

Browse files
Initial commit
0 parents  commit f5eb8e1

24 files changed

+1512
-0
lines changed

.appveyor.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
- "*"

.github/workflows/conda.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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/[email protected]
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

.github/workflows/format.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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/[email protected]

.github/workflows/pip.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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

.github/workflows/wheels.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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/[email protected]
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 }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build/
2+
dist/
3+
_build/
4+
_generate/
5+
*.so
6+
*.py[cod]
7+
*.egg-info
8+
*env*

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "pybind11"]
2+
path = pybind11
3+
url = https://github.com/pybind/pybind11.git
4+
branch = master

.pre-commit-config.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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})

0 commit comments

Comments
 (0)