From e0c3750ed6aff6642ee01ef9556cfff9f66ac665 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 15 Jul 2022 12:43:20 -0700 Subject: [PATCH 1/9] Comment out "hidden" in cmake files, setup_helpers.py, disable `PYBIND11_WERROR` --- pybind11/setup_helpers.py | 2 +- tests/CMakeLists.txt | 2 +- tools/pybind11NewTools.cmake | 12 ++++++------ tools/pybind11Tools.cmake | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pybind11/setup_helpers.py b/pybind11/setup_helpers.py index 1fd04b9154..97f063334b 100644 --- a/pybind11/setup_helpers.py +++ b/pybind11/setup_helpers.py @@ -149,7 +149,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: if WIN: cflags += ["/EHsc", "/bigobj"] else: - cflags += ["-fvisibility=hidden"] + # cflags += ["-fvisibility=hidden"] env_cflags = os.environ.get("CFLAGS", "") env_cppflags = os.environ.get("CPPFLAGS", "") c_cpp_flags = shlex.split(env_cflags) + shlex.split(env_cppflags) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e7aec339f3..903d95d460 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -387,7 +387,7 @@ function(pybind11_enable_warnings target_name) -Wnon-virtual-dtor) endif() - if(PYBIND11_WERROR) + if(PYBIND11_WERROR AND NOT PYBIND11_WERROR) # SILLY TRICK TO TURN OFF if(MSVC) target_compile_options(${target_name} PRIVATE /WX) elseif(PYBIND11_CUDA_TESTS) diff --git a/tools/pybind11NewTools.cmake b/tools/pybind11NewTools.cmake index abba0fe0e2..bd754809b1 100644 --- a/tools/pybind11NewTools.cmake +++ b/tools/pybind11NewTools.cmake @@ -208,13 +208,13 @@ function(pybind11_add_module target_name) # py::module_local). We force it on everything inside the `pybind11` # namespace; also turning it on for a pybind module compilation here avoids # potential warnings or issues from having mixed hidden/non-hidden types. - if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET) - set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden") - endif() + # if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET) + # set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden") + # endif() - if(NOT DEFINED CMAKE_CUDA_VISIBILITY_PRESET) - set_target_properties(${target_name} PROPERTIES CUDA_VISIBILITY_PRESET "hidden") - endif() + # if(NOT DEFINED CMAKE_CUDA_VISIBILITY_PRESET) + # set_target_properties(${target_name} PROPERTIES CUDA_VISIBILITY_PRESET "hidden") + # endif() # If we don't pass a WITH_SOABI or WITHOUT_SOABI, use our own default handling of extensions if(NOT ARG_WITHOUT_SOABI AND NOT "WITH_SOABI" IN_LIST ARG_UNPARSED_ARGUMENTS) diff --git a/tools/pybind11Tools.cmake b/tools/pybind11Tools.cmake index 5535e872f3..1f84ba27e6 100644 --- a/tools/pybind11Tools.cmake +++ b/tools/pybind11Tools.cmake @@ -188,13 +188,13 @@ function(pybind11_add_module target_name) # py::module_local). We force it on everything inside the `pybind11` # namespace; also turning it on for a pybind module compilation here avoids # potential warnings or issues from having mixed hidden/non-hidden types. - if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET) - set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden") - endif() + # if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET) + # set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden") + # endif() - if(NOT DEFINED CMAKE_CUDA_VISIBILITY_PRESET) - set_target_properties(${target_name} PROPERTIES CUDA_VISIBILITY_PRESET "hidden") - endif() + # if(NOT DEFINED CMAKE_CUDA_VISIBILITY_PRESET) + # set_target_properties(${target_name} PROPERTIES CUDA_VISIBILITY_PRESET "hidden") + # endif() if(ARG_NO_EXTRAS) return() From 1c19e80c87c7a46ac857ce9dace2e55b7d956396 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 15 Jul 2022 15:04:26 -0700 Subject: [PATCH 2/9] Restore PYBIND11_WERROR --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 903d95d460..e7aec339f3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -387,7 +387,7 @@ function(pybind11_enable_warnings target_name) -Wnon-virtual-dtor) endif() - if(PYBIND11_WERROR AND NOT PYBIND11_WERROR) # SILLY TRICK TO TURN OFF + if(PYBIND11_WERROR) if(MSVC) target_compile_options(${target_name} PRIVATE /WX) elseif(PYBIND11_CUDA_TESTS) From 2b924cb8629e5080deea3d8ae7b59275f3b23e3c Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 15 Jul 2022 18:42:50 -0700 Subject: [PATCH 3/9] Introduce `PYBIND11_NS_VISIBILITY(...)` macro, use to fix "declared with greater visibility" warnings. --- include/pybind11/detail/common.h | 4 +++- tests/test_class_sh_trampoline_basic.cpp | 4 ++-- tests/test_class_sh_virtual_py_cpp_mix.cpp | 4 ++-- tests/test_exceptions.cpp | 6 ++++++ tests/test_numpy_array.cpp | 6 ++++++ tests/test_pytypes.cpp | 4 ++-- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index aea1987bf5..1dbbe1fe5b 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -25,8 +25,10 @@ // on the main `pybind11` namespace. #if !defined(PYBIND11_NAMESPACE) # ifdef __GNUG__ -# define PYBIND11_NAMESPACE pybind11 __attribute__((visibility("hidden"))) +# define PYBIND11_NS_VISIBILITY(...) __VA_ARGS__ __attribute__((visibility("hidden"))) +# define PYBIND11_NAMESPACE PYBIND11_NS_VISIBILITY(pybind11) # else +# define PYBIND11_NS_VISIBILITY(...) # define PYBIND11_NAMESPACE pybind11 # endif #endif diff --git a/tests/test_class_sh_trampoline_basic.cpp b/tests/test_class_sh_trampoline_basic.cpp index e31bcf7198..4cda66090b 100644 --- a/tests/test_class_sh_trampoline_basic.cpp +++ b/tests/test_class_sh_trampoline_basic.cpp @@ -4,7 +4,7 @@ #include -namespace pybind11_tests { +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NS_VISIBILITY(pybind11_tests)) namespace class_sh_trampoline_basic { template // Using int as a trick to easily generate a series of types. @@ -74,7 +74,7 @@ void wrap(py::module_ m, const char *py_class_name) { } } // namespace class_sh_trampoline_basic -} // namespace pybind11_tests +PYBIND11_NAMESPACE_END(pybind11_tests) PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_trampoline_basic::Abase<0>) PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_trampoline_basic::Abase<1>) diff --git a/tests/test_class_sh_virtual_py_cpp_mix.cpp b/tests/test_class_sh_virtual_py_cpp_mix.cpp index 2fa9990a22..d486a5682e 100644 --- a/tests/test_class_sh_virtual_py_cpp_mix.cpp +++ b/tests/test_class_sh_virtual_py_cpp_mix.cpp @@ -4,7 +4,7 @@ #include -namespace pybind11_tests { +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NS_VISIBILITY(pybind11_tests)) namespace class_sh_virtual_py_cpp_mix { class Base { @@ -44,7 +44,7 @@ struct CppDerivedVirtualOverrider : CppDerived, py::trampoline_self_life_support }; } // namespace class_sh_virtual_py_cpp_mix -} // namespace pybind11_tests +PYBIND11_NAMESPACE_END(pybind11_tests) PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_virtual_py_cpp_mix::Base) PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::class_sh_virtual_py_cpp_mix::CppDerivedPlain) diff --git a/tests/test_exceptions.cpp b/tests/test_exceptions.cpp index 3ec999d1dc..25f48f7802 100644 --- a/tests/test_exceptions.cpp +++ b/tests/test_exceptions.cpp @@ -15,6 +15,8 @@ #include #include +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NS_VISIBILITY(pybind11_tests)) + // A type that should be raised as an exception in Python class MyException : public std::exception { public: @@ -110,7 +112,11 @@ std::string error_already_set_what(const py::object &exc_type, const py::object return py::error_already_set().what(); } +PYBIND11_NAMESPACE_END(pybind11_tests) + TEST_SUBMODULE(exceptions, m) { + using namespace pybind11_tests; + m.def("throw_std_exception", []() { throw std::runtime_error("This exception was intentionally thrown."); }); diff --git a/tests/test_numpy_array.cpp b/tests/test_numpy_array.cpp index 69ddbe1ef2..81639f06ec 100644 --- a/tests/test_numpy_array.cpp +++ b/tests/test_numpy_array.cpp @@ -15,6 +15,8 @@ #include #include +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NS_VISIBILITY(pybind11_tests)) + // Size / dtype checks. struct DtypeCheck { py::dtype numpy{}; @@ -159,7 +161,11 @@ py::handle auxiliaries(T &&r, T2 &&r2) { // note: declaration at local scope would create a dangling reference! static int data_i = 42; +PYBIND11_NAMESPACE_END(pybind11_tests) + TEST_SUBMODULE(numpy_array, sm) { + using namespace pybind11_tests; + try { py::module_::import("numpy"); } catch (const py::error_already_set &) { diff --git a/tests/test_pytypes.cpp b/tests/test_pytypes.cpp index cb81007c37..e2286240d2 100644 --- a/tests/test_pytypes.cpp +++ b/tests/test_pytypes.cpp @@ -11,7 +11,7 @@ #include -namespace external { +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NS_VISIBILITY(external)) namespace detail { bool check(PyObject *o) { return PyFloat_Check(o) != 0; } @@ -37,7 +37,7 @@ class float_ : public py::object { double get_value() const { return PyFloat_AsDouble(this->ptr()); } }; -} // namespace external +PYBIND11_NAMESPACE_END(external) TEST_SUBMODULE(pytypes, m) { // test_bool From cf84927bbdda6b224f564e2dea34d788e292d343 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 15 Jul 2022 18:48:20 -0700 Subject: [PATCH 4/9] Completely remove coded previously only commented out under commit e0c3750ed6aff6642ee01ef9556cfff9f66ac665 --- pybind11/setup_helpers.py | 1 - tools/pybind11NewTools.cmake | 13 ------------- tools/pybind11Tools.cmake | 13 ------------- 3 files changed, 27 deletions(-) diff --git a/pybind11/setup_helpers.py b/pybind11/setup_helpers.py index 97f063334b..1172406b4b 100644 --- a/pybind11/setup_helpers.py +++ b/pybind11/setup_helpers.py @@ -149,7 +149,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: if WIN: cflags += ["/EHsc", "/bigobj"] else: - # cflags += ["-fvisibility=hidden"] env_cflags = os.environ.get("CFLAGS", "") env_cppflags = os.environ.get("CPPFLAGS", "") c_cpp_flags = shlex.split(env_cflags) + shlex.split(env_cppflags) diff --git a/tools/pybind11NewTools.cmake b/tools/pybind11NewTools.cmake index bd754809b1..52306d0cfa 100644 --- a/tools/pybind11NewTools.cmake +++ b/tools/pybind11NewTools.cmake @@ -203,19 +203,6 @@ function(pybind11_add_module target_name) target_link_libraries(${target_name} PRIVATE pybind11::windows_extras) endif() - # -fvisibility=hidden is required to allow multiple modules compiled against - # different pybind versions to work properly, and for some features (e.g. - # py::module_local). We force it on everything inside the `pybind11` - # namespace; also turning it on for a pybind module compilation here avoids - # potential warnings or issues from having mixed hidden/non-hidden types. - # if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET) - # set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden") - # endif() - - # if(NOT DEFINED CMAKE_CUDA_VISIBILITY_PRESET) - # set_target_properties(${target_name} PROPERTIES CUDA_VISIBILITY_PRESET "hidden") - # endif() - # If we don't pass a WITH_SOABI or WITHOUT_SOABI, use our own default handling of extensions if(NOT ARG_WITHOUT_SOABI AND NOT "WITH_SOABI" IN_LIST ARG_UNPARSED_ARGUMENTS) pybind11_extension(${target_name}) diff --git a/tools/pybind11Tools.cmake b/tools/pybind11Tools.cmake index 1f84ba27e6..542fd92d68 100644 --- a/tools/pybind11Tools.cmake +++ b/tools/pybind11Tools.cmake @@ -183,19 +183,6 @@ function(pybind11_add_module target_name) pybind11_extension(${target_name}) - # -fvisibility=hidden is required to allow multiple modules compiled against - # different pybind versions to work properly, and for some features (e.g. - # py::module_local). We force it on everything inside the `pybind11` - # namespace; also turning it on for a pybind module compilation here avoids - # potential warnings or issues from having mixed hidden/non-hidden types. - # if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET) - # set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden") - # endif() - - # if(NOT DEFINED CMAKE_CUDA_VISIBILITY_PRESET) - # set_target_properties(${target_name} PROPERTIES CUDA_VISIBILITY_PRESET "hidden") - # endif() - if(ARG_NO_EXTRAS) return() endif() From 41f25a0d611024f36df6e5075d42656eccfc4650 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 15 Jul 2022 19:06:58 -0700 Subject: [PATCH 5/9] Fix silly mistake. --- include/pybind11/detail/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 1dbbe1fe5b..39531114cb 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -28,7 +28,7 @@ # define PYBIND11_NS_VISIBILITY(...) __VA_ARGS__ __attribute__((visibility("hidden"))) # define PYBIND11_NAMESPACE PYBIND11_NS_VISIBILITY(pybind11) # else -# define PYBIND11_NS_VISIBILITY(...) +# define PYBIND11_NS_VISIBILITY(...) __VA_ARGS__ # define PYBIND11_NAMESPACE pybind11 # endif #endif From f963a08e0883a8712fc46e6efc2be5d5cfa23967 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 15 Jul 2022 19:08:32 -0700 Subject: [PATCH 6/9] Add more `PYBIND11_NS_VISIBILITY` for `trampoline_self_life_support` --- tests/test_class_sh_trampoline_self_life_support.cpp | 6 +++++- tests/test_class_sh_trampoline_shared_from_this.cpp | 8 ++++++-- tests/test_class_sh_trampoline_unique_ptr.cpp | 8 +++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/test_class_sh_trampoline_self_life_support.cpp b/tests/test_class_sh_trampoline_self_life_support.cpp index c1eb035435..7630dcbfec 100644 --- a/tests/test_class_sh_trampoline_self_life_support.cpp +++ b/tests/test_class_sh_trampoline_self_life_support.cpp @@ -10,6 +10,7 @@ #include #include +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NS_VISIBILITY(pybind11_tests)) namespace { struct Big5 { // Also known as "rule of five". @@ -42,10 +43,13 @@ struct Big5Trampoline : Big5, py::trampoline_self_life_support { }; } // namespace +PYBIND11_NAMESPACE_END(pybind11_tests) -PYBIND11_SMART_HOLDER_TYPE_CASTERS(Big5) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::Big5) TEST_SUBMODULE(class_sh_trampoline_self_life_support, m) { + using namespace pybind11_tests; + py::classh(m, "Big5") .def(py::init()) .def_readonly("history", &Big5::history); diff --git a/tests/test_class_sh_trampoline_shared_from_this.cpp b/tests/test_class_sh_trampoline_shared_from_this.cpp index ae9f274659..fc3fb98cc9 100644 --- a/tests/test_class_sh_trampoline_shared_from_this.cpp +++ b/tests/test_class_sh_trampoline_shared_from_this.cpp @@ -8,6 +8,7 @@ #include #include +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NS_VISIBILITY(pybind11_tests)) namespace { struct Sft : std::enable_shared_from_this { @@ -99,11 +100,14 @@ std::shared_ptr make_pure_cpp_sft_shd_ptr(const std::string &history_seed) std::shared_ptr pass_through_shd_ptr(const std::shared_ptr &obj) { return obj; } } // namespace +PYBIND11_NAMESPACE_END(pybind11_tests) -PYBIND11_SMART_HOLDER_TYPE_CASTERS(Sft) -PYBIND11_SMART_HOLDER_TYPE_CASTERS(SftSharedPtrStash) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::Sft) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::SftSharedPtrStash) TEST_SUBMODULE(class_sh_trampoline_shared_from_this, m) { + using namespace pybind11_tests; + py::classh(m, "Sft") .def(py::init()) .def(py::init([](const std::string &history, int) { diff --git a/tests/test_class_sh_trampoline_unique_ptr.cpp b/tests/test_class_sh_trampoline_unique_ptr.cpp index 141a6e8b57..12b2df93f3 100644 --- a/tests/test_class_sh_trampoline_unique_ptr.cpp +++ b/tests/test_class_sh_trampoline_unique_ptr.cpp @@ -8,6 +8,7 @@ #include +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NS_VISIBILITY(pybind11_tests)) namespace { class Class { @@ -31,9 +32,11 @@ class Class { }; } // namespace +PYBIND11_NAMESPACE_END(pybind11_tests) -PYBIND11_SMART_HOLDER_TYPE_CASTERS(Class) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::Class) +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NS_VISIBILITY(pybind11_tests)) namespace { class PyClass : public Class, public py::trampoline_self_life_support { @@ -46,8 +49,11 @@ class PyClass : public Class, public py::trampoline_self_life_support { }; } // namespace +PYBIND11_NAMESPACE_END(pybind11_tests) TEST_SUBMODULE(class_sh_trampoline_unique_ptr, m) { + using namespace pybind11_tests; + py::classh(m, "Class") .def(py::init<>()) .def("set_val", &Class::setVal) From 9ae35d2ed577b2479639acee90e712a045025bdb Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 15 Jul 2022 19:53:37 -0700 Subject: [PATCH 7/9] Add more `PYBIND11_NS_VISIBILITY` to resolve CUDA and mingw warnings. --- tests/pybind11_cross_module_tests.cpp | 2 +- tests/test_custom_type_setup.cpp | 5 +++++ tests/test_exceptions.h | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/pybind11_cross_module_tests.cpp b/tests/pybind11_cross_module_tests.cpp index 9379f3f259..92182a646a 100644 --- a/tests/pybind11_cross_module_tests.cpp +++ b/tests/pybind11_cross_module_tests.cpp @@ -48,7 +48,7 @@ PYBIND11_MODULE(pybind11_cross_module_tests, m) { if (p) { std::rethrow_exception(p); } - } catch (const shared_exception &e) { + } catch (const pybind11_tests::shared_exception &e) { PyErr_SetString(PyExc_KeyError, e.what()); } }); diff --git a/tests/test_custom_type_setup.cpp b/tests/test_custom_type_setup.cpp index 42fae05d5d..057f4ad1f1 100644 --- a/tests/test_custom_type_setup.cpp +++ b/tests/test_custom_type_setup.cpp @@ -13,14 +13,19 @@ namespace py = pybind11; +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NS_VISIBILITY(pybind11_tests)) namespace { struct OwnsPythonObjects { py::object value = py::none(); }; + } // namespace +PYBIND11_NAMESPACE_END(pybind11_tests) TEST_SUBMODULE(custom_type_setup, m) { + using namespace pybind11_tests; + py::class_ cls( m, "OwnsPythonObjects", py::custom_type_setup([](PyHeapTypeObject *heap_type) { auto *type = &heap_type->ht_type; diff --git a/tests/test_exceptions.h b/tests/test_exceptions.h index 03684b89fa..adad7c6c4e 100644 --- a/tests/test_exceptions.h +++ b/tests/test_exceptions.h @@ -5,9 +5,13 @@ // shared exceptions for cross_module_tests +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NS_VISIBILITY(pybind11_tests)) + class PYBIND11_EXPORT_EXCEPTION shared_exception : public pybind11::builtin_exception { public: using builtin_exception::builtin_exception; explicit shared_exception() : shared_exception("") {} void set_error() const override { PyErr_SetString(PyExc_RuntimeError, what()); } }; + +PYBIND11_NAMESPACE_END(pybind11_tests) From c5ad26c57d011a357c43cb4bf86a0800ad20a0ec Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 15 Jul 2022 21:16:01 -0700 Subject: [PATCH 8/9] Rename test_exc_namespace_visibility.py back to test_namespace_visibility.py --- tests/CMakeLists.txt | 5 ++--- ...amespace_visibility.py => test_namespace_visibility.py} | 7 ------- 2 files changed, 2 insertions(+), 10 deletions(-) rename tests/{test_exc_namespace_visibility.py => test_namespace_visibility.py} (88%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e7aec339f3..c211290a73 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -148,7 +148,6 @@ set(PYBIND11_TEST_FILES test_eigen test_enum test_eval - test_exc_namespace_visibility.py test_exceptions test_factory_constructors test_gil_scoped @@ -158,6 +157,7 @@ set(PYBIND11_TEST_FILES test_methods_and_attributes test_modules test_multiple_inheritance + test_namespace_visibility.py test_numpy_array test_numpy_dtypes test_numpy_vectorize @@ -237,8 +237,7 @@ tests_extra_targets("test_exceptions.py" "cross_module_interleaved_error_already tests_extra_targets("test_gil_scoped.py" "cross_module_gil_utils") tests_extra_targets("test_class_sh_module_local.py" "class_sh_module_local_0;class_sh_module_local_1;class_sh_module_local_2") -tests_extra_targets("test_exc_namespace_visibility.py" - "namespace_visibility_1;namespace_visibility_2") +tests_extra_targets("test_namespace_visibility.py" "namespace_visibility_1;namespace_visibility_2") set(PYBIND11_EIGEN_REPO "https://gitlab.com/libeigen/eigen.git" diff --git a/tests/test_exc_namespace_visibility.py b/tests/test_namespace_visibility.py similarity index 88% rename from tests/test_exc_namespace_visibility.py rename to tests/test_namespace_visibility.py index 0f1cab9d5b..4d7919e5d5 100644 --- a/tests/test_exc_namespace_visibility.py +++ b/tests/test_namespace_visibility.py @@ -4,13 +4,6 @@ # `-fvisibility=hidden` or `__attribute__((visibility("hidden")))`, or linking # extensions statically with the core Python interpreter. -# NOTE -# ==== -# The "exc_" in "test_exc_namespace_visibility.py" is a workaround, to avoid a -# test_cross_module_exception_translator (test_exceptions.py) failure. This -# test has to be imported (by pytest) before test_exceptions.py; pytest sorts -# lexically. See https://github.com/pybind/pybind11/pull/4054 for more information. - import itertools import namespace_visibility_1 From fbf9a95e8b15dbc704d03fe29540cc7600204c0a Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 16 Jul 2022 09:09:07 -0700 Subject: [PATCH 9/9] Revert "Rename test_exc_namespace_visibility.py back to test_namespace_visibility.py" This reverts commit c5ad26c57d011a357c43cb4bf86a0800ad20a0ec. Observation summarized here: https://github.com/pybind/pybind11/pull/4054#issuecomment-1186227735 > ... the list of jobs that fail is still exactly like (... before) --- tests/CMakeLists.txt | 5 +++-- ...pace_visibility.py => test_exc_namespace_visibility.py} | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) rename tests/{test_namespace_visibility.py => test_exc_namespace_visibility.py} (88%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c211290a73..e7aec339f3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -148,6 +148,7 @@ set(PYBIND11_TEST_FILES test_eigen test_enum test_eval + test_exc_namespace_visibility.py test_exceptions test_factory_constructors test_gil_scoped @@ -157,7 +158,6 @@ set(PYBIND11_TEST_FILES test_methods_and_attributes test_modules test_multiple_inheritance - test_namespace_visibility.py test_numpy_array test_numpy_dtypes test_numpy_vectorize @@ -237,7 +237,8 @@ tests_extra_targets("test_exceptions.py" "cross_module_interleaved_error_already tests_extra_targets("test_gil_scoped.py" "cross_module_gil_utils") tests_extra_targets("test_class_sh_module_local.py" "class_sh_module_local_0;class_sh_module_local_1;class_sh_module_local_2") -tests_extra_targets("test_namespace_visibility.py" "namespace_visibility_1;namespace_visibility_2") +tests_extra_targets("test_exc_namespace_visibility.py" + "namespace_visibility_1;namespace_visibility_2") set(PYBIND11_EIGEN_REPO "https://gitlab.com/libeigen/eigen.git" diff --git a/tests/test_namespace_visibility.py b/tests/test_exc_namespace_visibility.py similarity index 88% rename from tests/test_namespace_visibility.py rename to tests/test_exc_namespace_visibility.py index 4d7919e5d5..0f1cab9d5b 100644 --- a/tests/test_namespace_visibility.py +++ b/tests/test_exc_namespace_visibility.py @@ -4,6 +4,13 @@ # `-fvisibility=hidden` or `__attribute__((visibility("hidden")))`, or linking # extensions statically with the core Python interpreter. +# NOTE +# ==== +# The "exc_" in "test_exc_namespace_visibility.py" is a workaround, to avoid a +# test_cross_module_exception_translator (test_exceptions.py) failure. This +# test has to be imported (by pytest) before test_exceptions.py; pytest sorts +# lexically. See https://github.com/pybind/pybind11/pull/4054 for more information. + import itertools import namespace_visibility_1