Skip to content

Commit e69ce1e

Browse files
authored
Merge pull request #40 from ssciwr/dont_ship_cpp_lib_in_python_wheels
Don't include c++ interface in Python wheel
2 parents 235c9df + 7ec29d3 commit e69ce1e

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
3+
rev: v4.6.0
44
hooks:
55
- id: check-yaml
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
88
- id: mixed-line-ending
99

1010
- repo: https://github.com/psf/black
11-
rev: 24.3.0
11+
rev: 24.4.2
1212
hooks:
1313
- id: black
1414

@@ -24,7 +24,7 @@ repos:
2424
- id: nbstripout
2525

2626
- repo: https://github.com/pre-commit/mirrors-clang-format
27-
rev: v18.1.2
27+
rev: v18.1.5
2828
hooks:
2929
- id: clang-format
3030

CMakeLists.txt

+25-21
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.15..3.29)
33
# Set a name and a version number for your project:
44
project(
55
pybind11-numpy-example
6-
VERSION 0.0.12
6+
VERSION 0.0.13
77
LANGUAGES CXX)
88

99
# Initialize some default paths
@@ -16,10 +16,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
1616
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1717

1818
# Configuration options
19-
option(BUILD_PYTHON "Enable building of Python bindings" ON)
19+
option(BUILD_CPP "Enable building of C++ interface" ON)
20+
option(BUILD_PYTHON "Enable building of Python interface" ON)
2021
option(BUILD_DOCS "Enable building of documentation" ON)
2122

22-
# Build the c++ library
23+
# Build the core c++ library
2324
add_subdirectory(lib)
2425

2526
# Build the c++ tests
@@ -35,31 +36,34 @@ if(BUILD_DOCS)
3536
add_subdirectory(doc)
3637
endif()
3738

38-
# Build the python bindings
39+
# Build the python interface
3940
if(BUILD_PYTHON)
4041
add_subdirectory(src)
4142
endif()
4243

43-
# Add an alias target for use if this project is included as a subproject in
44-
# another project
45-
add_library(pybind11_numpy_example::pybind11_numpy_example ALIAS
46-
pybind11_numpy_example)
44+
# Install c++ interface
45+
if(BUILD_CPP)
46+
# Add an alias target for use if this project is included as a subproject in
47+
# another project
48+
add_library(pybind11_numpy_example::pybind11_numpy_example ALIAS
49+
pybind11_numpy_example)
4750

48-
# Install targets and configuration
49-
install(
50-
TARGETS pybind11_numpy_example
51-
EXPORT pybind11_numpy_example_config
52-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
53-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
54-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
51+
# Install targets and configuration
52+
install(
53+
TARGETS pybind11_numpy_example
54+
EXPORT pybind11_numpy_example_config
55+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
56+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
57+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
5558

56-
install(
57-
EXPORT pybind11_numpy_example_config
58-
NAMESPACE pybind11_numpy_example::
59-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pybind11_numpy_example)
59+
install(
60+
EXPORT pybind11_numpy_example_config
61+
NAMESPACE pybind11_numpy_example::
62+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pybind11_numpy_example)
6063

61-
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
62-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
64+
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
65+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
66+
endif()
6367

6468
# This prints a summary of found dependencies
6569
include(FeatureSummary)

pyproject.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ build-backend = "scikit_build_core.build"
44

55
[project]
66
name = "pybind11-numpy-example"
7-
version = "0.0.12"
7+
version = "0.0.13"
88
description = "An example of using numpy with pybind11"
99
readme = "README.md"
1010
license = {text = "MIT"}
1111
authors=[{name="Liam Keegan", email="[email protected]"}]
1212
maintainers=[{name="Liam Keegan", email="[email protected]"}]
1313
requires-python = ">=3.7"
1414
dependencies = ["numpy"]
15-
keywords = ["pybind11", "cibuildwheel", "c++", "pypi", "numpy", "simple", "example"]
15+
keywords = ["pybind11", "cibuildwheel", "c++", "pypi", "numpy", "simple", "example", "wheel", "pypi", "conda-forge"]
1616
classifiers=[
1717
"Programming Language :: C++",
1818
"Programming Language :: Python :: 3 :: Only",
@@ -39,6 +39,7 @@ test = ["pytest"]
3939
docs = ["cmake", "breathe", "sphinx_rtd_theme"]
4040

4141
[tool.scikit-build.cmake.define]
42+
BUILD_CPP = "OFF"
4243
BUILD_PYTHON = "ON"
4344
BUILD_TESTING = "OFF"
4445
BUILD_DOCS = "OFF"

0 commit comments

Comments
 (0)