Skip to content

Move internal headers into detail subdirectory #1001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ set(PYTHON_MODULE_EXTENSION ${PYTHON_MODULE_EXTENSION} CACHE INTERNAL "")

# NB: when adding a header don't forget to also add it to setup.py
set(PYBIND11_HEADERS
include/pybind11/detail/class.h
include/pybind11/detail/common.h
include/pybind11/detail/descr.h
include/pybind11/detail/typeid.h
include/pybind11/attr.h
include/pybind11/buffer_info.h
include/pybind11/cast.h
include/pybind11/chrono.h
include/pybind11/class_support.h
include/pybind11/common.h
include/pybind11/complex.h
include/pybind11/descr.h
include/pybind11/options.h
include/pybind11/eigen.h
include/pybind11/embed.h
Expand All @@ -55,7 +56,6 @@ set(PYBIND11_HEADERS
include/pybind11/pytypes.h
include/pybind11/stl.h
include/pybind11/stl_bind.h
include/pybind11/typeid.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typeid.h does provide the non-detail namespace py::type_id<T>(), which is a fairly useful function and might be in use. Maybe this one should be left for later?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking here was that typeid.h is included anyway by cast.h and in turn by pybind11.h, so there's no way to lose out on py::type_id<T>() unless someone is using it without anything else from pybind11. But I wouldn't mind reverting it if I'm overlooking something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true; it's fine with me to include it in the move. (Maybe type_id() should be moved out into cast.h or somewhere else, but that's not really a big deal—and as an undocumented mostly internal function it was arguably misplaced by not being in detail in the first place).

)
string(REPLACE "include/" "${CMAKE_CURRENT_SOURCE_DIR}/include/"
PYBIND11_HEADERS "${PYBIND11_HEADERS}")
Expand All @@ -68,7 +68,7 @@ include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# extract project version from source
file(STRINGS "${PYBIND11_INCLUDE_DIR}/pybind11/common.h" pybind11_version_defines
file(STRINGS "${PYBIND11_INCLUDE_DIR}/pybind11/detail/common.h" pybind11_version_defines
REGEX "#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) ")
foreach(ver ${pybind11_version_defines})
if (ver MATCHES "#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$")
Expand Down Expand Up @@ -110,8 +110,7 @@ if(NOT (CMAKE_VERSION VERSION_LESS 3.0)) # CMake >= 3.0
endif()

if (PYBIND11_INSTALL)
install(FILES ${PYBIND11_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pybind11)
install(DIRECTORY ${PYBIND11_INCLUDE_DIR}/pybind11 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share".
set(PYBIND11_CMAKECONFIG_INSTALL_DIR "share/cmake/${PROJECT_NAME}" CACHE STRING "install path for pybind11Config.cmake")

Expand Down
2 changes: 1 addition & 1 deletion include/pybind11/buffer_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#pragma once

#include "common.h"
#include "detail/common.h"

NAMESPACE_BEGIN(PYBIND11_NAMESPACE)

Expand Down
4 changes: 2 additions & 2 deletions include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#pragma once

#include "pytypes.h"
#include "typeid.h"
#include "descr.h"
#include "detail/typeid.h"
#include "detail/descr.h"
#include <array>
#include <limits>
#include <tuple>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
pybind11/class_support.h: Python C API implementation details for py::class_
pybind11/detail/class.h: Python C API implementation details for py::class_

Copyright (c) 2017 Wenzel Jakob <[email protected]>

Expand All @@ -9,7 +9,7 @@

#pragma once

#include "attr.h"
#include "../attr.h"

NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
NAMESPACE_BEGIN(detail)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
pybind11/common.h -- Basic macros
pybind11/detail/common.h -- Basic macros

Copyright (c) 2016 Wenzel Jakob <[email protected]>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
pybind11/descr.h: Helper type for concatenating type signatures
pybind11/detail/descr.h: Helper type for concatenating type signatures
either at runtime (C++11) or compile time (C++14)

Copyright (c) 2016 Wenzel Jakob <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
pybind11/typeid.h: Compiler-independent access to type identifiers
pybind11/detail/typeid.h: Compiler-independent access to type identifiers

Copyright (c) 2016 Wenzel Jakob <[email protected]>

Expand Down
2 changes: 1 addition & 1 deletion include/pybind11/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#pragma once

#include "common.h"
#include "detail/common.h"

NAMESPACE_BEGIN(PYBIND11_NAMESPACE)

Expand Down
2 changes: 1 addition & 1 deletion include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

#include "attr.h"
#include "options.h"
#include "class_support.h"
#include "detail/class.h"

NAMESPACE_BEGIN(PYBIND11_NAMESPACE)

Expand Down
4 changes: 2 additions & 2 deletions include/pybind11/pytypes.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
pybind11/typeid.h: Convenience wrapper classes for basic Python types
pybind11/pytypes.h: Convenience wrapper classes for basic Python types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 👍


Copyright (c) 2016 Wenzel Jakob <[email protected]>

Expand All @@ -9,7 +9,7 @@

#pragma once

#include "common.h"
#include "detail/common.h"
#include "buffer_info.h"
#include <utility>
#include <type_traits>
Expand Down
2 changes: 1 addition & 1 deletion include/pybind11/stl_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#pragma once

#include "common.h"
#include "detail/common.h"
#include "operators.h"

#include <algorithm>
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
headers = []
else:
headers = [
'include/pybind11/detail/class.h',
'include/pybind11/detail/common.h',
'include/pybind11/detail/descr.h',
'include/pybind11/detail/typeid.h'
'include/pybind11/attr.h',
'include/pybind11/buffer_info.h',
'include/pybind11/cast.h',
'include/pybind11/chrono.h',
'include/pybind11/class_support.h',
'include/pybind11/common.h',
'include/pybind11/complex.h',
'include/pybind11/descr.h',
'include/pybind11/eigen.h',
'include/pybind11/embed.h',
'include/pybind11/eval.h',
Expand All @@ -31,7 +32,6 @@
'include/pybind11/pytypes.h',
'include/pybind11/stl.h',
'include/pybind11/stl_bind.h',
'include/pybind11/typeid.h'
]

setup(
Expand Down