Skip to content

Commit 8831515

Browse files
committed
update
0 parents  commit 8831515

7 files changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build Python Wheels
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
release:
8+
branches:
9+
- main
10+
types: [published]
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
14+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
15+
16+
jobs:
17+
build-wheels:
18+
name: Build Python Wheels (${{ matrix.OS }})
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
OS: ["ubuntu-24.04", "windows-2022"]
23+
24+
runs-on: ${{ matrix.OS }}
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 1
31+
show-progress: true
32+
33+
- name: Resolve release version
34+
if: github.event_name == 'release'
35+
id: release_version
36+
shell: bash
37+
run: |
38+
tag="${GITHUB_REF_NAME}"
39+
echo "value=${tag#v}" >> "$GITHUB_OUTPUT"
40+
41+
- name: Build wheels (release version)
42+
if: github.event_name == 'release'
43+
uses: pypa/cibuildwheel@v3.1.0
44+
env:
45+
CIBW_BUILD_FRONTEND: "build"
46+
CIBW_BUILD_FRONTEND_ARGS: "--config-setting=metadata.version=${{ steps.release_version.outputs.value }}"
47+
with:
48+
output-dir: wheelhouse
49+
50+
- name: Build wheels (PR)
51+
if: github.event_name != 'release'
52+
uses: pypa/cibuildwheel@v3.1.0
53+
with:
54+
output-dir: wheelhouse
55+
56+
- name: Upload wheels
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: wheelhouse-${{ matrix.OS }}
60+
path: wheelhouse/*.whl

‎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.18)
2+
3+
project(hello_cpp VERSION 0.1.0 LANGUAGES CXX)
4+
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
find_package(pybind11 CONFIG REQUIRED)
9+
10+
pybind11_add_module(hello_cpp src/hello.cpp)

‎README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# hello-cpp
2+
3+
Minimal C++ hello world module exported with pybind11 and built via CMake.
4+
5+
```python
6+
import hello_cpp
7+
8+
print(hello_cpp.hello())
9+
```
995 Bytes
Binary file not shown.

‎dist/hello_cpp-0.1.0.tar.gz‎

1.48 KB
Binary file not shown.

‎pyproject.toml‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[build-system]
2+
requires = ["scikit-build-core>=0.9.0", "pybind11>=2.11.0"]
3+
build-backend = "scikit_build_core.build"
4+
5+
[project]
6+
name = "hello-cpp"
7+
dynamic = ["version"]
8+
description = "Minimal pybind11 hello world module built with CMake."
9+
readme = "README.md"
10+
requires-python = ">=3.8"
11+
license = { text = "MIT" }
12+
authors = [{ name = "Example Author" }]
13+
classifiers = [
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: C++",
16+
"License :: OSI Approved :: MIT License",
17+
]
18+
19+
[tool.scikit-build]
20+
minimum-version = "0.9"
21+
cmake.version = ">=3.18"
22+
build-dir = "build/{wheel_tag}"
23+
wheel.packages = []
24+
25+
[tool.scikit-build.metadata]
26+
version = "0.0.0"

‎src/hello.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <pybind11/pybind11.h>
2+
3+
namespace py = pybind11;
4+
5+
std::string hello() {
6+
return "Hello from C++!";
7+
}
8+
9+
PYBIND11_MODULE(hello_cpp, m) {
10+
m.doc() = "Minimal hello world pybind11 module";
11+
m.def("hello", &hello, "Return a friendly greeting from C++");
12+
}

0 commit comments

Comments
 (0)