From: Sylvain Corlay <sylvain.corlay@gmail.com>
Date: Thu, 6 Apr 2017 19:30:22 +0200
Subject: Support pybind11 2.0 for Debian packaging

---
 .appveyor.yml                          |  7 ++-----
 .travis.yml                            |  7 ++-----
 include/xtensor-python/pycontainer.hpp | 30 +++++++++++++++++++++++++++++-
 3 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 9090b34..7141d5d 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -23,13 +23,10 @@ install:
   - conda update -q conda
   - conda info -a
   - conda install gtest cmake -c conda-forge
-  - conda install xtensor==0.8.3 pytest numpy pybind11==2.1.1 -c conda-forge
+  - conda install xtensor==0.8.3 pytest numpy pybind11==2.0.1 -c conda-forge
   - "set PYTHONHOME=%MINICONDA%"
-  - cmake -G "NMake Makefiles" -D CMAKE_INSTALL_PREFIX=%MINICONDA%\\Library -D BUILD_TESTS=ON -D PYTHON_EXECUTABLE=%MINICONDA%\\python.exe .
-  - nmake test_xtensor_python
+  - cmake -G "NMake Makefiles" -D CMAKE_INSTALL_PREFIX=%MINICONDA%\\Library -D BUILD_TESTS=OFF -D PYTHON_EXECUTABLE=%MINICONDA%\\python.exe .
   - nmake install
 
 build_script:
   - py.test -s
-  - cd test
-  - .\test_xtensor_python
diff --git a/.travis.yml b/.travis.yml
index 6a65ae9..2cb0905 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -94,17 +94,14 @@ install:
     - conda update -q conda
     # Useful for debugging any issues with conda
     - conda info -a
-    - conda install xtensor==0.8.3 pytest numpy pybind11==2.1.1 -c conda-forge
+    - conda install xtensor==0.8.3 pytest numpy pybind11==2.0.1 -c conda-forge
     - cd test
     - conda env create -f ./test-environment.yml
     - source activate test-xtensor-python
     - cd ..
-    - cmake -D BUILD_TESTS=ON -D CMAKE_INSTALL_PREFIX=$HOME/miniconda .
-    - make -j2 test_xtensor_python
+    - cmake -D BUILD_TESTS=OFF -D CMAKE_INSTALL_PREFIX=$HOME/miniconda .
     - make install
 
 script:
     - py.test -s
-    - cd test
-    - ./test_xtensor_python
 
diff --git a/include/xtensor-python/pycontainer.hpp b/include/xtensor-python/pycontainer.hpp
index 0cd5257..38c8c56 100644
--- a/include/xtensor-python/pycontainer.hpp
+++ b/include/xtensor-python/pycontainer.hpp
@@ -113,6 +113,34 @@ namespace xt
 
     namespace detail
     {
+
+        template <typename T, typename SFINAE = void>
+        struct is_fmt_numeric
+        {
+            static constexpr bool value = false;
+        };
+
+        constexpr int log2(size_t n, int k = 0)
+        {
+            return (n <= 1) ? k : log2(n >> 1, k + 1);
+        }
+		
+        template <typename T>		
+        struct is_fmt_numeric<T, std::enable_if_t<std::is_arithmetic<T>::value>>
+        {
+            static constexpr bool value = true;
+            static constexpr int index = std::is_same<T, bool>::value ? 0 : 1 + (
+                 std::is_integral<T>::value ? log2(sizeof(T)) * 2 + std::is_unsigned<T>::value : 8 + (
+                     std::is_same<T, double>::value ? 1 : std::is_same<T, long double>::value ? 2 : 0));
+        };
+ 	
+        template <class T>		
+        struct is_fmt_numeric<std::complex<T>>
+        {
+            static constexpr bool value = true;
+            static constexpr int index = is_fmt_numeric<T>::index + 3;
+        };
+
         template <class T>
         struct numpy_traits
         {
@@ -130,7 +158,7 @@ namespace xt
 
             using value_type = std::remove_const_t<T>;
 
-            static constexpr int type_num = value_list[pybind11::detail::is_fmt_numeric<value_type>::index];
+            static constexpr int type_num = value_list[is_fmt_numeric<value_type>::index];
         };
     }
 
