From d5ce82b6f577433100fcd65160469fbfec24b0f6 Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Tue, 14 Feb 2017 13:16:14 +0100 Subject: [PATCH] CMake installation path consistency (#652) * Add flag for installation of headers under python include directory * Allow the disabling of distutils install_headers --- CMakeLists.txt | 5 +++++ setup.py | 32 ++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec104b0b5..63f34830b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,11 @@ endforeach() set(${PROJECT_NAME}_VERSION ${PYBIND11_VERSION_MAJOR}.${PYBIND11_VERSION_MINOR}.${PYBIND11_VERSION_PATCH}) message(STATUS "pybind11 v${${PROJECT_NAME}_VERSION}") +option (USE_PYTHON_INCLUDE_DIR "Install pybind11 headers in Python include directory instead of default installation prefix" OFF) +if (USE_PYTHON_INCLUDE_DIR) + file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_INCLUDE_DIRS}) +endif() + if(NOT (CMAKE_VERSION VERSION_LESS 3.0)) # CMake >= 3.0 # Build an interface library target: add_library(module INTERFACE) diff --git a/setup.py b/setup.py index a25f1af40..f3011b0dd 100644 --- a/setup.py +++ b/setup.py @@ -4,18 +4,14 @@ from setuptools import setup from pybind11 import __version__ +import os -setup( - name='pybind11', - version=__version__, - description='Seamless operability between C++11 and Python', - author='Wenzel Jakob', - author_email='wenzel.jakob@epfl.ch', - url='https://github.com/wjakob/pybind11', - download_url='https://github.com/wjakob/pybind11/tarball/v' + __version__, - packages=['pybind11'], - license='BSD', - headers=[ +# Prevent installation of pybind11 headers by setting +# PYBIND11_USE_CMAKE. +if os.environ.get('PYBIND11_USE_CMAKE'): + headers = [] +else: + headers = [ 'include/pybind11/attr.h', 'include/pybind11/cast.h', 'include/pybind11/chrono.h', @@ -33,7 +29,19 @@ setup( 'include/pybind11/stl.h', 'include/pybind11/stl_bind.h', 'include/pybind11/typeid.h' - ], + ] + +setup( + name='pybind11', + version=__version__, + description='Seamless operability between C++11 and Python', + author='Wenzel Jakob', + author_email='wenzel.jakob@epfl.ch', + url='https://github.com/wjakob/pybind11', + download_url='https://github.com/wjakob/pybind11/tarball/v' + __version__, + packages=['pybind11'], + license='BSD', + headers=headers, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers',