Skip to content

Commit 9907943

Browse files
committed
Merge branch 'master' into type_caster_PyObject_master
2 parents f6c7cee + 6de6191 commit 9907943

17 files changed

+247
-21
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
run: brew install boost
8383

8484
- name: Update CMake
85-
uses: jwlawson/actions-setup-cmake@v1.13
85+
uses: jwlawson/actions-setup-cmake@v1.14
8686

8787
- name: Cache wheels
8888
if: runner.os == 'macOS'
@@ -164,7 +164,6 @@ jobs:
164164
-DDOWNLOAD_EIGEN=ON
165165
-DCMAKE_CXX_STANDARD=17
166166
-DPYBIND11_INTERNALS_VERSION=10000000
167-
"-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp"
168167
${{ matrix.args }}
169168
170169
- name: Build (unstable ABI)
@@ -208,7 +207,7 @@ jobs:
208207
debug: ${{ matrix.python-debug }}
209208

210209
- name: Update CMake
211-
uses: jwlawson/actions-setup-cmake@v1.13
210+
uses: jwlawson/actions-setup-cmake@v1.14
212211

213212
- name: Valgrind cache
214213
if: matrix.valgrind
@@ -474,7 +473,7 @@ jobs:
474473
run: python3 -m pip install --upgrade pip
475474

476475
- name: Update CMake
477-
uses: jwlawson/actions-setup-cmake@v1.13
476+
uses: jwlawson/actions-setup-cmake@v1.14
478477

479478
- name: Configure
480479
shell: bash
@@ -497,6 +496,24 @@ jobs:
497496
- name: Interface test
498497
run: cmake --build build --target test_cmake_build
499498

499+
- name: Configure - Exercise cmake -DPYBIND11_TEST_OVERRIDE
500+
if: matrix.gcc == '12'
501+
shell: bash
502+
run: >
503+
cmake -S . -B build_partial
504+
-DPYBIND11_WERROR=ON
505+
-DDOWNLOAD_CATCH=ON
506+
-DCMAKE_CXX_STANDARD=${{ matrix.std }}
507+
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
508+
"-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp"
509+
510+
- name: Build - Exercise cmake -DPYBIND11_TEST_OVERRIDE
511+
if: matrix.gcc == '12'
512+
run: cmake --build build_partial -j 2
513+
514+
- name: Python tests - Exercise cmake -DPYBIND11_TEST_OVERRIDE
515+
if: matrix.gcc == '12'
516+
run: cmake --build build_partial --target pytest
500517

501518
# Testing on ICC using the oneAPI apt repo
502519
icc:
@@ -763,7 +780,7 @@ jobs:
763780
architecture: x86
764781

765782
- name: Update CMake
766-
uses: jwlawson/actions-setup-cmake@v1.13
783+
uses: jwlawson/actions-setup-cmake@v1.14
767784

768785
- name: Prepare MSVC
769786
uses: ilammy/[email protected]
@@ -816,7 +833,7 @@ jobs:
816833
architecture: x86
817834

818835
- name: Update CMake
819-
uses: jwlawson/actions-setup-cmake@v1.13
836+
uses: jwlawson/actions-setup-cmake@v1.14
820837

821838
- name: Prepare MSVC
822839
uses: ilammy/[email protected]
@@ -867,7 +884,7 @@ jobs:
867884
python3 -m pip install -r tests/requirements.txt
868885
869886
- name: Update CMake
870-
uses: jwlawson/actions-setup-cmake@v1.13
887+
uses: jwlawson/actions-setup-cmake@v1.14
871888

872889
- name: Configure C++20
873890
run: >
@@ -889,6 +906,21 @@ jobs:
889906
- name: Interface test C++20
890907
run: cmake --build build --target test_cmake_build
891908

909+
- name: Configure C++20 - Exercise cmake -DPYBIND11_TEST_OVERRIDE
910+
run: >
911+
cmake -S . -B build_partial
912+
-DPYBIND11_WERROR=ON
913+
-DDOWNLOAD_CATCH=ON
914+
-DDOWNLOAD_EIGEN=ON
915+
-DCMAKE_CXX_STANDARD=20
916+
"-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp"
917+
918+
- name: Build C++20 - Exercise cmake -DPYBIND11_TEST_OVERRIDE
919+
run: cmake --build build_partial -j 2
920+
921+
- name: Python tests - Exercise cmake -DPYBIND11_TEST_OVERRIDE
922+
run: cmake --build build_partial --target pytest
923+
892924
mingw:
893925
name: "🐍 3 • windows-latest • ${{ matrix.sys }}"
894926
runs-on: windows-latest
@@ -1000,7 +1032,7 @@ jobs:
10001032
python-version: ${{ matrix.python }}
10011033

10021034
- name: Update CMake
1003-
uses: jwlawson/actions-setup-cmake@v1.13
1035+
uses: jwlawson/actions-setup-cmake@v1.14
10041036

10051037
- name: Install ninja-build tool
10061038
uses: seanmiddleditch/gha-setup-ninja@v3
@@ -1070,7 +1102,7 @@ jobs:
10701102
run: clang++ --version
10711103

10721104
- name: Update CMake
1073-
uses: jwlawson/actions-setup-cmake@v1.13
1105+
uses: jwlawson/actions-setup-cmake@v1.14
10741106

10751107
- name: Run pip installs
10761108
run: |
@@ -1105,5 +1137,23 @@ jobs:
11051137
- name: Interface test
11061138
run: cmake --build . --target test_cmake_build -j 2
11071139

1140+
- name: CMake Configure - Exercise cmake -DPYBIND11_TEST_OVERRIDE
1141+
run: >
1142+
cmake -S . -B build_partial
1143+
-DPYBIND11_WERROR=ON
1144+
-DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF
1145+
-DDOWNLOAD_CATCH=ON
1146+
-DDOWNLOAD_EIGEN=ON
1147+
-DCMAKE_CXX_COMPILER=clang++
1148+
-DCMAKE_CXX_STANDARD=17
1149+
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
1150+
"-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp"
1151+
1152+
- name: Build - Exercise cmake -DPYBIND11_TEST_OVERRIDE
1153+
run: cmake --build build_partial -j 2
1154+
1155+
- name: Python tests - Exercise cmake -DPYBIND11_TEST_OVERRIDE
1156+
run: cmake --build build_partial --target pytest -j 2
1157+
11081158
- name: Clean directory
11091159
run: git clean -fdx

.github/workflows/configure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
# An action for adding a specific version of CMake:
5656
# https://github.com/jwlawson/actions-setup-cmake
5757
- name: Setup CMake ${{ matrix.cmake }}
58-
uses: jwlawson/actions-setup-cmake@v1.13
58+
uses: jwlawson/actions-setup-cmake@v1.14
5959
with:
6060
cmake-version: ${{ matrix.cmake }}
6161

.github/workflows/pip.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ jobs:
9898
- uses: actions/download-artifact@v3
9999

100100
- name: Publish standard package
101-
uses: pypa/[email protected].4
101+
uses: pypa/[email protected].5
102102
with:
103103
password: ${{ secrets.pypi_password }}
104104
packages-dir: standard/
105105

106106
- name: Publish global package
107-
uses: pypa/[email protected].4
107+
uses: pypa/[email protected].5
108108
with:
109109
password: ${{ secrets.pypi_password_global }}
110110
packages-dir: global/

.github/workflows/upstream.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
run: sudo apt-get install libboost-dev
3434

3535
- name: Update CMake
36-
uses: jwlawson/actions-setup-cmake@v1.13
36+
uses: jwlawson/actions-setup-cmake@v1.14
3737

3838
- name: Run pip installs
3939
run: |
@@ -95,7 +95,6 @@ jobs:
9595
-DDOWNLOAD_EIGEN=ON
9696
-DCMAKE_CXX_STANDARD=17
9797
-DPYBIND11_INTERNALS_VERSION=10000000
98-
"-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp"
9998
10099
- name: Build (unstable ABI)
101100
run: cmake --build build17max -j 2

docs/classes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ interactive Python session demonstrating this example is shown below:
5858
Static member functions can be bound in the same way using
5959
:func:`class_::def_static`.
6060

61+
.. note::
62+
63+
Binding C++ types in unnamed namespaces (also known as anonymous namespaces)
64+
works reliably on many platforms, but not all. The `XFAIL_CONDITION` in
65+
tests/test_unnamed_namespace_a.py encodes the currently known conditions.
66+
For background see `#4319 <https://github.com/pybind/pybind11/pull/4319>`_.
67+
If portability is a concern, it is therefore not recommended to bind C++
68+
types in unnamed namespaces. It will be safest to manually pick unique
69+
namespace names.
70+
6171
Keyword and default arguments
6272
=============================
6373
It is possible to specify keyword and default arguments using the syntax

include/pybind11/cast.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ struct move_always<
964964
enable_if_t<
965965
all_of<move_is_plain_type<T>,
966966
negation<is_copy_constructible<T>>,
967-
std::is_move_constructible<T>,
967+
is_move_constructible<T>,
968968
std::is_same<decltype(std::declval<make_caster<T>>().operator T &()), T &>>::value>>
969969
: std::true_type {};
970970
template <typename T, typename SFINAE = void>
@@ -975,7 +975,7 @@ struct move_if_unreferenced<
975975
enable_if_t<
976976
all_of<move_is_plain_type<T>,
977977
negation<move_always<T>>,
978-
std::is_move_constructible<T>,
978+
is_move_constructible<T>,
979979
std::is_same<decltype(std::declval<make_caster<T>>().operator T &()), T &>>::value>>
980980
: std::true_type {};
981981
template <typename T>

include/pybind11/detail/init.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void construct(value_and_holder &v_h, Holder<Class> holder, bool need_alias) {
175175
template <typename Class>
176176
void construct(value_and_holder &v_h, Cpp<Class> &&result, bool need_alias) {
177177
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias);
178-
static_assert(std::is_move_constructible<Cpp<Class>>::value,
178+
static_assert(is_move_constructible<Cpp<Class>>::value,
179179
"pybind11::init() return-by-value factory function requires a movable class");
180180
if (Class::has_alias && need_alias) {
181181
construct_alias_from_cpp<Class>(is_alias_constructible<Class>{}, v_h, std::move(result));
@@ -190,7 +190,7 @@ void construct(value_and_holder &v_h, Cpp<Class> &&result, bool need_alias) {
190190
template <typename Class>
191191
void construct(value_and_holder &v_h, Alias<Class> &&result, bool) {
192192
static_assert(
193-
std::is_move_constructible<Alias<Class>>::value,
193+
is_move_constructible<Alias<Class>>::value,
194194
"pybind11::init() return-by-alias-value factory function requires a movable alias class");
195195
v_h.value_ptr() = new Alias<Class>(std::move(result));
196196
}

include/pybind11/detail/internals.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ inline void tls_replace_value(PYBIND11_TLS_KEY_REF key, void *value) {
123123
// libstdc++, this doesn't happen: equality and the type_index hash are based on the type name,
124124
// which works. If not under a known-good stl, provide our own name-based hash and equality
125125
// functions that use the type name.
126-
#if defined(__GLIBCXX__)
126+
#if (PYBIND11_INTERNALS_VERSION <= 4 && defined(__GLIBCXX__)) \
127+
|| (PYBIND11_INTERNALS_VERSION >= 5 && !defined(_LIBCPP_VERSION))
127128
inline bool same_type(const std::type_info &lhs, const std::type_info &rhs) { return lhs == rhs; }
128129
using type_hash = std::hash<std::type_index>;
129130
using type_equal_to = std::equal_to<std::type_index>;

include/pybind11/detail/type_caster_base.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,9 @@ using movable_cast_op_type
827827
template <typename T, typename SFINAE = void>
828828
struct is_copy_constructible : std::is_copy_constructible<T> {};
829829

830+
template <typename T, typename SFINAE = void>
831+
struct is_move_constructible : std::is_move_constructible<T> {};
832+
830833
// Specialization for types that appear to be copy constructible but also look like stl containers
831834
// (we specifically check for: has `value_type` and `reference` with `reference = value_type&`): if
832835
// so, copy constructability depends on whether the value_type is copy constructible.
@@ -994,7 +997,7 @@ class type_caster_base : public type_caster_generic {
994997
return [](const void *arg) -> void * { return new T(*reinterpret_cast<const T *>(arg)); };
995998
}
996999

997-
template <typename T, typename = enable_if_t<std::is_move_constructible<T>::value>>
1000+
template <typename T, typename = enable_if_t<is_move_constructible<T>::value>>
9981001
static auto make_move_constructor(const T *)
9991002
-> decltype(new T(std::declval<T &&>()), Constructor{}) {
10001003
return [](const void *arg) -> void * {

tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ set(PYBIND11_TEST_FILES
156156
test_thread
157157
test_type_caster_pyobject_ptr
158158
test_union
159+
test_unnamed_namespace_a
160+
test_unnamed_namespace_b
161+
test_vector_unique_ptr_member
159162
test_virtual_functions)
160163

161164
# Invoking cmake with something like:

0 commit comments

Comments
 (0)