Skip to content

Commit d5ce82b

Browse files
SylvainCorlaywjakob
authored andcommitted
CMake installation path consistency (#652)
* Add flag for installation of headers under python include directory * Allow the disabling of distutils install_headers
1 parent cec052b commit d5ce82b

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ endforeach()
9292
set(${PROJECT_NAME}_VERSION ${PYBIND11_VERSION_MAJOR}.${PYBIND11_VERSION_MINOR}.${PYBIND11_VERSION_PATCH})
9393
message(STATUS "pybind11 v${${PROJECT_NAME}_VERSION}")
9494

95+
option (USE_PYTHON_INCLUDE_DIR "Install pybind11 headers in Python include directory instead of default installation prefix" OFF)
96+
if (USE_PYTHON_INCLUDE_DIR)
97+
file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_INCLUDE_DIRS})
98+
endif()
99+
95100
if(NOT (CMAKE_VERSION VERSION_LESS 3.0)) # CMake >= 3.0
96101
# Build an interface library target:
97102
add_library(module INTERFACE)

setup.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@
44

55
from setuptools import setup
66
from pybind11 import __version__
7+
import os
78

8-
setup(
9-
name='pybind11',
10-
version=__version__,
11-
description='Seamless operability between C++11 and Python',
12-
author='Wenzel Jakob',
13-
author_email='wenzel.jakob@epfl.ch',
14-
url='https://github.com/wjakob/pybind11',
15-
download_url='https://github.com/wjakob/pybind11/tarball/v' + __version__,
16-
packages=['pybind11'],
17-
license='BSD',
18-
headers=[
9+
# Prevent installation of pybind11 headers by setting
10+
# PYBIND11_USE_CMAKE.
11+
if os.environ.get('PYBIND11_USE_CMAKE'):
12+
headers = []
13+
else:
14+
headers = [
1915
'include/pybind11/attr.h',
2016
'include/pybind11/cast.h',
2117
'include/pybind11/chrono.h',
@@ -33,7 +29,19 @@
3329
'include/pybind11/stl.h',
3430
'include/pybind11/stl_bind.h',
3531
'include/pybind11/typeid.h'
36-
],
32+
]
33+
34+
setup(
35+
name='pybind11',
36+
version=__version__,
37+
description='Seamless operability between C++11 and Python',
38+
author='Wenzel Jakob',
39+
author_email='wenzel.jakob@epfl.ch',
40+
url='https://github.com/wjakob/pybind11',
41+
download_url='https://github.com/wjakob/pybind11/tarball/v' + __version__,
42+
packages=['pybind11'],
43+
license='BSD',
44+
headers=headers,
3745
classifiers=[
3846
'Development Status :: 5 - Production/Stable',
3947
'Intended Audience :: Developers',

0 commit comments

Comments
 (0)