From a3d0974ee5ae2f8035c7f4d2bc34a860d14c3678 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 9 Oct 2020 21:23:54 -0700 Subject: [PATCH 01/22] CI: Intel icc/icpc via oneAPI Add testing for Intel icc/icpc via the oneAPI images. Intel oneAPI is in a late beta stage, currently shipping oneAPI beta09 with ICC 20.2. --- .github/workflows/ci.yml | 73 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c45adab284..3fef6ec8a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -334,6 +334,7 @@ jobs: - name: Interface test run: cmake3 --build build --target test_cmake_build + # Testing on GCC using the GCC docker images (only recent images supported) gcc: runs-on: ubuntu-latest @@ -388,6 +389,78 @@ jobs: run: cmake --build build --target test_cmake_build + # Testing on ICC using the oneAPI apt repo + icc: + runs-on: ubuntu-latest + strategy: + fail-fast: false + + name: "🐍 3 • ICC latest • x64" + container: "gcc" + + steps: + - uses: actions/checkout@v1 + + - name: Add apt repo + run: | + apt-get update + apt-get install -y wget build-essential pkg-config cmake ca-certificates gnupg + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + echo "deb https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list + + - name: Add ICC & Python 3 + run: apt-get update; apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro intel-oneapi-python + + - name: Update pip & pytest + shell: bash + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + python -m pip install --upgrade pip + python -m pip install --upgrade pytest + + - name: Setup CMake 3.18 + uses: jwlawson/actions-setup-cmake@v1.4 + with: + cmake-version: 3.18 + + - name: Configure + shell: bash + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake -S . -B build \ + -DPYBIND11_WERROR=ON \ + -DDOWNLOAD_CATCH=ON \ + -DDOWNLOAD_EIGEN=ON \ + -DCMAKE_CXX_STANDARD=11 \ + -DCMAKE_CXX_COMPILER=$(which icpc) \ + -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") + + - name: Build + shell: bash + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake --build build -j 2 + + - name: Python tests + shell: bash + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake --build build --target pytest + + - name: C++ tests + shell: bash + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake --build build --target cpptest + + - name: Interface test + shell: bash + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake --build build --target test_cmake_build + + # Testing on CentOS (manylinux uses a centos base, and this is an easy way # to get GCC 4.8, which is the manylinux1 compiler). centos: From b729ef2539120f05cde201ce0d6ddaf80ae107cc Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sat, 10 Oct 2020 01:42:15 -0700 Subject: [PATCH 02/22] CI: Skip Interpreter Tests for Intel Cannot find how to add this, neiter the package `libc6-dev` nor `intel-oneapi-mkl-devel` help when installed to solve this: ``` -- Looking for C++ include pthread.h -- Looking for C++ include pthread.h - not found CMake Error at /__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message): Could NOT find Threads (missing: Threads_FOUND) Call Stack (most recent call first): /__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE) /__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindThreads.cmake:234 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) tests/test_embed/CMakeLists.txt:17 (find_package) ``` --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fef6ec8a5..b823b0267d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -430,7 +430,7 @@ jobs: set +e; source /opt/intel/oneapi/setvars.sh; set -e cmake -S . -B build \ -DPYBIND11_WERROR=ON \ - -DDOWNLOAD_CATCH=ON \ + -DDOWNLOAD_CATCH=OFF \ -DDOWNLOAD_EIGEN=ON \ -DCMAKE_CXX_STANDARD=11 \ -DCMAKE_CXX_COMPILER=$(which icpc) \ From aca821323bdb6f8bab90002bf457e10966e33b3f Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sat, 10 Oct 2020 01:53:14 -0700 Subject: [PATCH 03/22] CI: libc6-dev from GCC for ICC --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b823b0267d..97f0294ddb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -410,7 +410,7 @@ jobs: echo "deb https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list - name: Add ICC & Python 3 - run: apt-get update; apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro intel-oneapi-python + run: apt-get update; apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro intel-oneapi-python libc6-dev - name: Update pip & pytest shell: bash From fb78fe7993dd2db90f75b8ede83f2cf3ed17ed03 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sat, 10 Oct 2020 13:38:14 -0700 Subject: [PATCH 04/22] CI: Run bare metal for oneAPI --- .github/workflows/ci.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97f0294ddb..84d1c7784c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -396,21 +396,20 @@ jobs: fail-fast: false name: "🐍 3 • ICC latest • x64" - container: "gcc" steps: - uses: actions/checkout@v1 - name: Add apt repo run: | - apt-get update - apt-get install -y wget build-essential pkg-config cmake ca-certificates gnupg + sudo apt-get update + sudo apt-get install -y wget build-essential pkg-config cmake ca-certificates gnupg wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB - apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB - echo "deb https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list + sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list - name: Add ICC & Python 3 - run: apt-get update; apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro intel-oneapi-python libc6-dev + run: sudo apt-get update; sudo apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro intel-oneapi-python - name: Update pip & pytest shell: bash From 2aa9d5bf5526720700fb68d4571cb7048da53fa9 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sat, 10 Oct 2020 23:18:33 -0700 Subject: [PATCH 05/22] CI: Ubuntu 18.04 for oneAPI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84d1c7784c..c2c3fb45af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -391,7 +391,7 @@ jobs: # Testing on ICC using the oneAPI apt repo icc: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 strategy: fail-fast: false From 2f16b5fd445df0f38f0120cfb038117138b46072 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sat, 10 Oct 2020 23:41:02 -0700 Subject: [PATCH 06/22] CI: Intel +Catch -Eigen --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2c3fb45af..e965d14bf1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -429,8 +429,8 @@ jobs: set +e; source /opt/intel/oneapi/setvars.sh; set -e cmake -S . -B build \ -DPYBIND11_WERROR=ON \ - -DDOWNLOAD_CATCH=OFF \ - -DDOWNLOAD_EIGEN=ON \ + -DDOWNLOAD_CATCH=ON \ + -DDOWNLOAD_EIGEN=OFF \ -DCMAKE_CXX_STANDARD=11 \ -DCMAKE_CXX_COMPILER=$(which icpc) \ -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") From db15179d5fcb4f9d47d2676ce91b616497aac8fe Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sat, 10 Oct 2020 23:58:17 -0700 Subject: [PATCH 07/22] CI: CMake from Apt (ICC tests) --- .github/workflows/ci.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e965d14bf1..11e9fbaa90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -409,7 +409,7 @@ jobs: echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list - name: Add ICC & Python 3 - run: sudo apt-get update; sudo apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro intel-oneapi-python + run: sudo apt-get update; sudo apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro intel-oneapi-python cmake - name: Update pip & pytest shell: bash @@ -418,11 +418,6 @@ jobs: python -m pip install --upgrade pip python -m pip install --upgrade pytest - - name: Setup CMake 3.18 - uses: jwlawson/actions-setup-cmake@v1.4 - with: - cmake-version: 3.18 - - name: Configure shell: bash run: | From f644ce2290dba3a1f092c5e2eef4a68e3c7ec874 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sun, 11 Oct 2020 00:18:42 -0700 Subject: [PATCH 08/22] CI: Replace Intel Py with GCC Py --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11e9fbaa90..046f5ed58c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -409,14 +409,14 @@ jobs: echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list - name: Add ICC & Python 3 - run: sudo apt-get update; sudo apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro intel-oneapi-python cmake + run: sudo apt-get update; sudo apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro cmake python3-dev python3-numpy python3-pytest python3-pip libeigen3-dev - name: Update pip & pytest shell: bash run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - python -m pip install --upgrade pip - python -m pip install --upgrade pytest + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade pytest - name: Configure shell: bash @@ -428,7 +428,7 @@ jobs: -DDOWNLOAD_EIGEN=OFF \ -DCMAKE_CXX_STANDARD=11 \ -DCMAKE_CXX_COMPILER=$(which icpc) \ - -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") - name: Build shell: bash From 4d19cfcf581212c6254e57c9cb97d37446a838ed Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sun, 11 Oct 2020 13:06:01 -0700 Subject: [PATCH 09/22] CI: Intel w/o GCC's Eigen --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 046f5ed58c..4f095461fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -409,7 +409,7 @@ jobs: echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list - name: Add ICC & Python 3 - run: sudo apt-get update; sudo apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro cmake python3-dev python3-numpy python3-pytest python3-pip libeigen3-dev + run: sudo apt-get update; sudo apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro cmake python3-dev python3-numpy python3-pytest python3-pip - name: Update pip & pytest shell: bash From d6ec3a3065e7b9a4f4515b0db5a28667a6c9477e Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sun, 11 Oct 2020 13:09:13 -0700 Subject: [PATCH 10/22] CI: ICC with verbose make --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f095461fe..d58343b3a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -428,6 +428,7 @@ jobs: -DDOWNLOAD_EIGEN=OFF \ -DCMAKE_CXX_STANDARD=11 \ -DCMAKE_CXX_COMPILER=$(which icpc) \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") - name: Build From 0a7d97d6ec7de33c76be09230ce82c475a7dfa25 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sun, 11 Oct 2020 14:12:26 -0700 Subject: [PATCH 11/22] [Debug] Find core dump --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d58343b3a9..58622a2704 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -441,7 +441,9 @@ jobs: shell: bash run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build --target pytest + sudo service apport stop + cmake --build build --target pytest; ls; ls /home/runner/work/pybind11/pybind11/build/tests + exit 1 - name: C++ tests shell: bash From d4296ec9f8fe1f5b60de9654e48d447513d6523f Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 23 Nov 2020 11:54:28 -0500 Subject: [PATCH 12/22] tests: use arg{} instead of arg() for Intel --- tests/test_builtin_casters.cpp | 2 +- tests/test_custom_type_casters.cpp | 16 ++++++++-------- tests/test_eigen.cpp | 8 ++++---- tests/test_methods_and_attributes.cpp | 14 +++++++------- tests/test_numpy_array.cpp | 20 ++++++++++---------- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/test_builtin_casters.cpp b/tests/test_builtin_casters.cpp index e16c2d62bc..c7b4138d1d 100644 --- a/tests/test_builtin_casters.cpp +++ b/tests/test_builtin_casters.cpp @@ -185,7 +185,7 @@ TEST_SUBMODULE(builtin_casters, m) { // test_bool_caster m.def("bool_passthrough", [](bool arg) { return arg; }); - m.def("bool_passthrough_noconvert", [](bool arg) { return arg; }, py::arg().noconvert()); + m.def("bool_passthrough_noconvert", [](bool arg) { return arg; }, py::arg{}.noconvert()); // test_reference_wrapper m.def("refwrap_builtin", [](std::reference_wrapper p) { return 10 * p.get(); }); diff --git a/tests/test_custom_type_casters.cpp b/tests/test_custom_type_casters.cpp index d565add264..377bfb62e4 100644 --- a/tests/test_custom_type_casters.cpp +++ b/tests/test_custom_type_casters.cpp @@ -101,17 +101,17 @@ TEST_SUBMODULE(custom_type_casters, m) { }; py::class_(m, "ArgInspector") .def(py::init<>()) - .def("f", &ArgInspector::f, py::arg(), py::arg() = ArgAlwaysConverts()) - .def("g", &ArgInspector::g, "a"_a.noconvert(), "b"_a, "c"_a.noconvert()=13, "d"_a=ArgInspector2(), py::arg() = ArgAlwaysConverts()) - .def_static("h", &ArgInspector::h, py::arg().noconvert(), py::arg() = ArgAlwaysConverts()) + .def("f", &ArgInspector::f, py::arg{}, py::arg{} = ArgAlwaysConverts()) + .def("g", &ArgInspector::g, "a"_a.noconvert(), "b"_a, "c"_a.noconvert()=13, "d"_a=ArgInspector2(), py::arg{} = ArgAlwaysConverts()) + .def_static("h", &ArgInspector::h, py::arg{}.noconvert(), py::arg{} = ArgAlwaysConverts()) ; m.def("arg_inspect_func", [](ArgInspector2 a, ArgInspector1 b, ArgAlwaysConverts) { return a.arg + "\n" + b.arg; }, - py::arg().noconvert(false), py::arg_v(nullptr, ArgInspector1()).noconvert(true), py::arg() = ArgAlwaysConverts()); + py::arg{}.noconvert(false), py::arg_v{nullptr, ArgInspector1()}.noconvert(true), py::arg{} = ArgAlwaysConverts()); - m.def("floats_preferred", [](double f) { return 0.5 * f; }, py::arg("f")); - m.def("floats_only", [](double f) { return 0.5 * f; }, py::arg("f").noconvert()); - m.def("ints_preferred", [](int i) { return i / 2; }, py::arg("i")); - m.def("ints_only", [](int i) { return i / 2; }, py::arg("i").noconvert()); + m.def("floats_preferred", [](double f) { return 0.5 * f; }, py::arg{"f"}); + m.def("floats_only", [](double f) { return 0.5 * f; }, py::arg{"f"}.noconvert()); + m.def("ints_preferred", [](int i) { return i / 2; }, py::arg{"i"}); + m.def("ints_only", [](int i) { return i / 2; }, py::arg{"i"}.noconvert()); // test_custom_caster_destruction // Test that `take_ownership` works on types with a custom type caster when given a pointer diff --git a/tests/test_eigen.cpp b/tests/test_eigen.cpp index 2cc2243d6f..4f92489bd0 100644 --- a/tests/test_eigen.cpp +++ b/tests/test_eigen.cpp @@ -280,17 +280,17 @@ TEST_SUBMODULE(eigen, m) { m.def("get_elem", &get_elem); // Now this alternative that calls the tells pybind to fail rather than copy: m.def("get_elem_nocopy", [](Eigen::Ref m) -> double { return get_elem(m); }, - py::arg().noconvert()); + py::arg{}.noconvert()); // Also test a row-major-only no-copy const ref: m.def("get_elem_rm_nocopy", [](Eigen::Ref> &m) -> long { return m(2, 1); }, - py::arg().noconvert()); + py::arg{}.noconvert()); // test_issue738 // Issue #738: 1xN or Nx1 2D matrices were neither accepted nor properly copied with an // incompatible stride value on the length-1 dimension--but that should be allowed (without // requiring a copy!) because the stride value can be safely ignored on a size-1 dimension. - m.def("iss738_f1", &adjust_matrix &>, py::arg().noconvert()); - m.def("iss738_f2", &adjust_matrix> &>, py::arg().noconvert()); + m.def("iss738_f1", &adjust_matrix &>, py::arg{}.noconvert()); + m.def("iss738_f2", &adjust_matrix> &>, py::arg{}.noconvert()); // test_issue1105 // Issue #1105: when converting from a numpy two-dimensional (Nx1) or (1xN) value into a dense diff --git a/tests/test_methods_and_attributes.cpp b/tests/test_methods_and_attributes.cpp index 6a2cfb6f7a..2982e835b2 100644 --- a/tests/test_methods_and_attributes.cpp +++ b/tests/test_methods_and_attributes.cpp @@ -325,15 +325,15 @@ TEST_SUBMODULE(methods_and_attributes, m) { // test_accepts_none py::class_>(m, "NoneTester") .def(py::init<>()); - m.def("no_none1", &none1, py::arg().none(false)); - m.def("no_none2", &none2, py::arg().none(false)); - m.def("no_none3", &none3, py::arg().none(false)); - m.def("no_none4", &none4, py::arg().none(false)); - m.def("no_none5", &none5, py::arg().none(false)); + m.def("no_none1", &none1, py::arg{}.none(false)); + m.def("no_none2", &none2, py::arg{}.none(false)); + m.def("no_none3", &none3, py::arg{}.none(false)); + m.def("no_none4", &none4, py::arg{}.none(false)); + m.def("no_none5", &none5, py::arg{}.none(false)); m.def("ok_none1", &none1); - m.def("ok_none2", &none2, py::arg().none(true)); + m.def("ok_none2", &none2, py::arg{}.none(true)); m.def("ok_none3", &none3); - m.def("ok_none4", &none4, py::arg().none(true)); + m.def("ok_none4", &none4, py::arg{}.none(true)); m.def("ok_none5", &none5); m.def("no_none_kwarg", &none2, py::arg("a").none(false)); diff --git a/tests/test_numpy_array.cpp b/tests/test_numpy_array.cpp index a84de77f8e..105cce4b10 100644 --- a/tests/test_numpy_array.cpp +++ b/tests/test_numpy_array.cpp @@ -259,8 +259,8 @@ TEST_SUBMODULE(numpy_array, sm) { sm.def("overloaded2", [](py::array_t) { return "float"; }); // Only accept the exact types: - sm.def("overloaded3", [](py::array_t) { return "int"; }, py::arg().noconvert()); - sm.def("overloaded3", [](py::array_t) { return "double"; }, py::arg().noconvert()); + sm.def("overloaded3", [](py::array_t) { return "int"; }, py::arg{}.noconvert()); + sm.def("overloaded3", [](py::array_t) { return "double"; }, py::arg{}.noconvert()); // Make sure we don't do unsafe coercion (e.g. float to int) when not using forcecast, but // rather that float gets converted via the safe (conversion to double) overload: @@ -284,7 +284,7 @@ TEST_SUBMODULE(numpy_array, sm) { for (py::ssize_t i = 0; i < r.shape(0); i++) for (py::ssize_t j = 0; j < r.shape(1); j++) r(i, j) += v; - }, py::arg().noconvert(), py::arg()); + }, py::arg{}.noconvert(), py::arg()); sm.def("proxy_init3", [](double start) { py::array_t a({ 3, 3, 3 }); @@ -338,7 +338,7 @@ TEST_SUBMODULE(numpy_array, sm) { for (py::ssize_t i = 0; i < r.shape(0); i++) for (py::ssize_t j = 0; j < r.shape(1); j++) r(i, j) += v; - }, py::arg().noconvert(), py::arg()); + }, py::arg{}.noconvert(), py::arg()); sm.def("proxy_init3_dyn", [](double start) { py::array_t a({ 3, 3, 3 }); auto r = a.mutable_unchecked(); @@ -419,20 +419,20 @@ TEST_SUBMODULE(numpy_array, sm) { py::arg("a")); sm.def("accept_double_noconvert", [](py::array_t) {}, - py::arg("a").noconvert()); + py::arg{"a"}.noconvert()); sm.def("accept_double_forcecast_noconvert", [](py::array_t) {}, - py::arg("a").noconvert()); + py::arg{"a"}.noconvert()); sm.def("accept_double_c_style_noconvert", [](py::array_t) {}, - py::arg("a").noconvert()); + py::arg{"a"}.noconvert()); sm.def("accept_double_c_style_forcecast_noconvert", [](py::array_t) {}, - py::arg("a").noconvert()); + py::arg{"a"}.noconvert()); sm.def("accept_double_f_style_noconvert", [](py::array_t) {}, - py::arg("a").noconvert()); + py::arg{"a"}.noconvert()); sm.def("accept_double_f_style_forcecast_noconvert", [](py::array_t) {}, - py::arg("a").noconvert()); + py::arg{"a"}.noconvert()); } From 8315fd7a821ae1e730aa5be2cbed7a391a6665dd Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 23 Nov 2020 17:32:05 -0500 Subject: [PATCH 13/22] tests: adding a few more missing {} --- tests/test_methods_and_attributes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_methods_and_attributes.cpp b/tests/test_methods_and_attributes.cpp index 2982e835b2..ffcc713c5c 100644 --- a/tests/test_methods_and_attributes.cpp +++ b/tests/test_methods_and_attributes.cpp @@ -336,8 +336,8 @@ TEST_SUBMODULE(methods_and_attributes, m) { m.def("ok_none4", &none4, py::arg{}.none(true)); m.def("ok_none5", &none5); - m.def("no_none_kwarg", &none2, py::arg("a").none(false)); - m.def("no_none_kwarg_kw_only", &none2, py::kw_only(), py::arg("a").none(false)); + m.def("no_none_kwarg", &none2, py::arg{"a"}.none(false)); + m.def("no_none_kwarg_kw_only", &none2, py::kw_only(), py::arg{"a"}.none(false)); // test_str_issue // Issue #283: __str__ called on uninitialized instance when constructor arguments invalid From fa5287f89377432373a702902b98d203dc35cf4a Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 23 Nov 2020 19:31:51 -0500 Subject: [PATCH 14/22] fix: sync with @tobiasleibner's branch --- tests/test_callbacks.cpp | 2 +- tests/test_class.cpp | 1 + tests/test_custom_type_casters.cpp | 12 ++++++------ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/test_callbacks.cpp b/tests/test_callbacks.cpp index 683dfb3efe..08bff6cf06 100644 --- a/tests/test_callbacks.cpp +++ b/tests/test_callbacks.cpp @@ -119,7 +119,7 @@ TEST_SUBMODULE(callbacks, m) { class AbstractBase { public: - virtual ~AbstractBase() = default; + virtual ~AbstractBase() {}; virtual unsigned int func() = 0; }; m.def("func_accepting_func_accepting_base", [](std::function) { }); diff --git a/tests/test_class.cpp b/tests/test_class.cpp index 523d954c52..9163f00577 100644 --- a/tests/test_class.cpp +++ b/tests/test_class.cpp @@ -323,6 +323,7 @@ TEST_SUBMODULE(class_, m) { class PublicistB : public ProtectedB { public: + ~PublicistB() override {}; using ProtectedB::foo; }; diff --git a/tests/test_custom_type_casters.cpp b/tests/test_custom_type_casters.cpp index 377bfb62e4..a2350e422a 100644 --- a/tests/test_custom_type_casters.cpp +++ b/tests/test_custom_type_casters.cpp @@ -101,16 +101,16 @@ TEST_SUBMODULE(custom_type_casters, m) { }; py::class_(m, "ArgInspector") .def(py::init<>()) - .def("f", &ArgInspector::f, py::arg{}, py::arg{} = ArgAlwaysConverts()) - .def("g", &ArgInspector::g, "a"_a.noconvert(), "b"_a, "c"_a.noconvert()=13, "d"_a=ArgInspector2(), py::arg{} = ArgAlwaysConverts()) - .def_static("h", &ArgInspector::h, py::arg{}.noconvert(), py::arg{} = ArgAlwaysConverts()) + .def("f", &ArgInspector::f, py::arg(), py::arg() = ArgAlwaysConverts()) + .def("g", &ArgInspector::g, "a"_a.noconvert(), "b"_a, "c"_a.noconvert()=13, "d"_a=ArgInspector2(), py::arg() = ArgAlwaysConverts()) + .def_static("h", &ArgInspector::h, py::arg{}.noconvert(), py::arg() = ArgAlwaysConverts()) ; m.def("arg_inspect_func", [](ArgInspector2 a, ArgInspector1 b, ArgAlwaysConverts) { return a.arg + "\n" + b.arg; }, - py::arg{}.noconvert(false), py::arg_v{nullptr, ArgInspector1()}.noconvert(true), py::arg{} = ArgAlwaysConverts()); + py::arg{}.noconvert(false), py::arg_v(nullptr, ArgInspector1()).noconvert(true), py::arg() = ArgAlwaysConverts()); - m.def("floats_preferred", [](double f) { return 0.5 * f; }, py::arg{"f"}); + m.def("floats_preferred", [](double f) { return 0.5 * f; }, py::arg("f")); m.def("floats_only", [](double f) { return 0.5 * f; }, py::arg{"f"}.noconvert()); - m.def("ints_preferred", [](int i) { return i / 2; }, py::arg{"i"}); + m.def("ints_preferred", [](int i) { return i / 2; }, py::arg("i")); m.def("ints_only", [](int i) { return i / 2; }, py::arg{"i"}.noconvert()); // test_custom_caster_destruction From 2da64e3b35adcc21c31ec7f2e4d40f2810ded230 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 25 Nov 2020 11:50:50 -0500 Subject: [PATCH 15/22] fix: try ubuntu 20-04 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58622a2704..fb38c02878 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -391,7 +391,7 @@ jobs: # Testing on ICC using the oneAPI apt repo icc: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 strategy: fail-fast: false From 125f6815f7fb5afc96b34961c88ad9f46f33d50b Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 25 Nov 2020 13:45:39 -0500 Subject: [PATCH 16/22] fix: drop exit 1 --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb38c02878..618d6399c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -442,8 +442,7 @@ jobs: run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e sudo service apport stop - cmake --build build --target pytest; ls; ls /home/runner/work/pybind11/pybind11/build/tests - exit 1 + cmake --build build --target check - name: C++ tests shell: bash From 3d592342f35905c860a108da6d1e63e9090b4fdd Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 15 Dec 2020 21:28:44 -0500 Subject: [PATCH 17/22] style: clang tidy fix --- tests/test_callbacks.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_callbacks.cpp b/tests/test_callbacks.cpp index 08bff6cf06..3506a192bb 100644 --- a/tests/test_callbacks.cpp +++ b/tests/test_callbacks.cpp @@ -119,7 +119,8 @@ TEST_SUBMODULE(callbacks, m) { class AbstractBase { public: - virtual ~AbstractBase() {}; + // ICC can't handle this being defaulted + virtual ~AbstractBase() {}; // NOLINT virtual unsigned int func() = 0; }; m.def("func_accepting_func_accepting_base", [](std::function) { }); From 451e4bc335ac9c31fd30b744bb50ea6a495575b7 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 18 Dec 2020 19:46:29 -0500 Subject: [PATCH 18/22] style: fix missing NOLINT --- tests/test_class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_class.cpp b/tests/test_class.cpp index 9163f00577..578281297d 100644 --- a/tests/test_class.cpp +++ b/tests/test_class.cpp @@ -323,7 +323,7 @@ TEST_SUBMODULE(class_, m) { class PublicistB : public ProtectedB { public: - ~PublicistB() override {}; + ~PublicistB() override {}; // NOLINT(modernize-use-equals-default) breaks ICPC using ProtectedB::foo; }; From cea3af896ff231c90f31f544f1950689c10a0959 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 22 Dec 2020 18:43:53 -0800 Subject: [PATCH 19/22] ICC: Update Compiler Name Changed upstream with the last oneAPI release. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 618d6399c8..02921d7524 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -409,7 +409,7 @@ jobs: echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list - name: Add ICC & Python 3 - run: sudo apt-get update; sudo apt-get install -y intel-oneapi-dpcpp-cpp-compiler-pro cmake python3-dev python3-numpy python3-pytest python3-pip + run: sudo apt-get update; sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic cmake python3-dev python3-numpy python3-pytest python3-pip - name: Update pip & pytest shell: bash From d03055a11a3a578e2db88bfe5a73df297a705a63 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 22 Dec 2020 20:00:36 -0800 Subject: [PATCH 20/22] ICC CI: Downgrade pytest pytest 6 does not capture the `discard_as_unraisable` stderr and just writes a warning with its content instead. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02921d7524..5494dbe194 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -416,7 +416,7 @@ jobs: run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e python3 -m pip install --upgrade pip - python3 -m pip install --upgrade pytest + python3 -m pip install --upgrade pytest==5.4.3 - name: Configure shell: bash From 59ebfdc1bd5858e0b4bf6798d8cb4c029cd845e1 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Sun, 3 Jan 2021 20:44:34 -0800 Subject: [PATCH 21/22] Use new test pinning requirements.txt --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5494dbe194..3e8fa28b56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -411,12 +411,15 @@ jobs: - name: Add ICC & Python 3 run: sudo apt-get update; sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic cmake python3-dev python3-numpy python3-pytest python3-pip - - name: Update pip & pytest + - name: Update pip shell: bash run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e python3 -m pip install --upgrade pip - python3 -m pip install --upgrade pytest==5.4.3 + + - name: Install dependencies + set +e; source /opt/intel/oneapi/setvars.sh; set -e + python3 -m pip install -r tests/requirements.txt --prefer-binary - name: Configure shell: bash From 7e0a08edb4b6803119d28587fa82348e7148facf Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 14 Jan 2021 10:31:21 -0500 Subject: [PATCH 22/22] tests: add notes about intel, cleanup --- .github/workflows/ci.yml | 1 + tests/test_builtin_casters.cpp | 2 ++ tests/test_callbacks.cpp | 4 ++-- tests/test_class.cpp | 3 ++- tests/test_custom_type_casters.cpp | 9 +++++---- tests/test_eigen.cpp | 1 + tests/test_methods_and_attributes.cpp | 6 ++++-- tests/test_numpy_array.cpp | 14 ++++++++------ 8 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e8fa28b56..badc966e69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -418,6 +418,7 @@ jobs: python3 -m pip install --upgrade pip - name: Install dependencies + run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e python3 -m pip install -r tests/requirements.txt --prefer-binary diff --git a/tests/test_builtin_casters.cpp b/tests/test_builtin_casters.cpp index c7b4138d1d..79144594c8 100644 --- a/tests/test_builtin_casters.cpp +++ b/tests/test_builtin_casters.cpp @@ -183,6 +183,8 @@ TEST_SUBMODULE(builtin_casters, m) { m.def("load_nullptr_t", [](std::nullptr_t) {}); // not useful, but it should still compile m.def("cast_nullptr_t", []() { return std::nullptr_t{}; }); + // [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works. + // test_bool_caster m.def("bool_passthrough", [](bool arg) { return arg; }); m.def("bool_passthrough_noconvert", [](bool arg) { return arg; }, py::arg{}.noconvert()); diff --git a/tests/test_callbacks.cpp b/tests/test_callbacks.cpp index 3506a192bb..a29a3db7b8 100644 --- a/tests/test_callbacks.cpp +++ b/tests/test_callbacks.cpp @@ -119,8 +119,8 @@ TEST_SUBMODULE(callbacks, m) { class AbstractBase { public: - // ICC can't handle this being defaulted - virtual ~AbstractBase() {}; // NOLINT + // [workaround(intel)] = default does not work here + virtual ~AbstractBase() {}; // NOLINT(modernize-use-equals-default) virtual unsigned int func() = 0; }; m.def("func_accepting_func_accepting_base", [](std::function) { }); diff --git a/tests/test_class.cpp b/tests/test_class.cpp index 578281297d..43b3ff9d31 100644 --- a/tests/test_class.cpp +++ b/tests/test_class.cpp @@ -323,7 +323,8 @@ TEST_SUBMODULE(class_, m) { class PublicistB : public ProtectedB { public: - ~PublicistB() override {}; // NOLINT(modernize-use-equals-default) breaks ICPC + // [workaround(intel)] = default does not work here + ~PublicistB() override {}; // NOLINT(modernize-use-equals-default) using ProtectedB::foo; }; diff --git a/tests/test_custom_type_casters.cpp b/tests/test_custom_type_casters.cpp index a2350e422a..3fe910d491 100644 --- a/tests/test_custom_type_casters.cpp +++ b/tests/test_custom_type_casters.cpp @@ -99,6 +99,7 @@ TEST_SUBMODULE(custom_type_casters, m) { } static ArgInspector2 h(ArgInspector2 a, ArgAlwaysConverts) { return a; } }; + // [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works. py::class_(m, "ArgInspector") .def(py::init<>()) .def("f", &ArgInspector::f, py::arg(), py::arg() = ArgAlwaysConverts()) @@ -108,10 +109,10 @@ TEST_SUBMODULE(custom_type_casters, m) { m.def("arg_inspect_func", [](ArgInspector2 a, ArgInspector1 b, ArgAlwaysConverts) { return a.arg + "\n" + b.arg; }, py::arg{}.noconvert(false), py::arg_v(nullptr, ArgInspector1()).noconvert(true), py::arg() = ArgAlwaysConverts()); - m.def("floats_preferred", [](double f) { return 0.5 * f; }, py::arg("f")); - m.def("floats_only", [](double f) { return 0.5 * f; }, py::arg{"f"}.noconvert()); - m.def("ints_preferred", [](int i) { return i / 2; }, py::arg("i")); - m.def("ints_only", [](int i) { return i / 2; }, py::arg{"i"}.noconvert()); + m.def("floats_preferred", [](double f) { return 0.5 * f; }, "f"_a); + m.def("floats_only", [](double f) { return 0.5 * f; }, "f"_a.noconvert()); + m.def("ints_preferred", [](int i) { return i / 2; }, "i"_a); + m.def("ints_only", [](int i) { return i / 2; }, "i"_a.noconvert()); // test_custom_caster_destruction // Test that `take_ownership` works on types with a custom type caster when given a pointer diff --git a/tests/test_eigen.cpp b/tests/test_eigen.cpp index 4f92489bd0..8432547439 100644 --- a/tests/test_eigen.cpp +++ b/tests/test_eigen.cpp @@ -273,6 +273,7 @@ TEST_SUBMODULE(eigen, m) { m.def("cpp_ref_r", [](py::handle m) { return m.cast>()(1, 0); }); m.def("cpp_ref_any", [](py::handle m) { return m.cast>()(1, 0); }); + // [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works. // test_nocopy_wrapper // Test that we can prevent copying into an argument that would normally copy: First a version diff --git a/tests/test_methods_and_attributes.cpp b/tests/test_methods_and_attributes.cpp index ffcc713c5c..f99909bda7 100644 --- a/tests/test_methods_and_attributes.cpp +++ b/tests/test_methods_and_attributes.cpp @@ -322,6 +322,8 @@ TEST_SUBMODULE(methods_and_attributes, m) { m.def("should_fail", [](int, UnregisteredType) {}, py::arg(), py::arg() = UnregisteredType()); }); + // [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works. + // test_accepts_none py::class_>(m, "NoneTester") .def(py::init<>()); @@ -336,8 +338,8 @@ TEST_SUBMODULE(methods_and_attributes, m) { m.def("ok_none4", &none4, py::arg{}.none(true)); m.def("ok_none5", &none5); - m.def("no_none_kwarg", &none2, py::arg{"a"}.none(false)); - m.def("no_none_kwarg_kw_only", &none2, py::kw_only(), py::arg{"a"}.none(false)); + m.def("no_none_kwarg", &none2, "a"_a.none(false)); + m.def("no_none_kwarg_kw_only", &none2, py::kw_only(), "a"_a.none(false)); // test_str_issue // Issue #283: __str__ called on uninitialized instance when constructor arguments invalid diff --git a/tests/test_numpy_array.cpp b/tests/test_numpy_array.cpp index 105cce4b10..dca7145f9d 100644 --- a/tests/test_numpy_array.cpp +++ b/tests/test_numpy_array.cpp @@ -258,6 +258,8 @@ TEST_SUBMODULE(numpy_array, sm) { sm.def("overloaded2", [](py::array_t>) { return "float complex"; }); sm.def("overloaded2", [](py::array_t) { return "float"; }); + // [workaround(intel)] ICC 20/21 breaks with py::arg().stuff, using py::arg{}.stuff works. + // Only accept the exact types: sm.def("overloaded3", [](py::array_t) { return "int"; }, py::arg{}.noconvert()); sm.def("overloaded3", [](py::array_t) { return "double"; }, py::arg{}.noconvert()); @@ -419,20 +421,20 @@ TEST_SUBMODULE(numpy_array, sm) { py::arg("a")); sm.def("accept_double_noconvert", [](py::array_t) {}, - py::arg{"a"}.noconvert()); + "a"_a.noconvert()); sm.def("accept_double_forcecast_noconvert", [](py::array_t) {}, - py::arg{"a"}.noconvert()); + "a"_a.noconvert()); sm.def("accept_double_c_style_noconvert", [](py::array_t) {}, - py::arg{"a"}.noconvert()); + "a"_a.noconvert()); sm.def("accept_double_c_style_forcecast_noconvert", [](py::array_t) {}, - py::arg{"a"}.noconvert()); + "a"_a.noconvert()); sm.def("accept_double_f_style_noconvert", [](py::array_t) {}, - py::arg{"a"}.noconvert()); + "a"_a.noconvert()); sm.def("accept_double_f_style_forcecast_noconvert", [](py::array_t) {}, - py::arg{"a"}.noconvert()); + "a"_a.noconvert()); }