File tree Expand file tree Collapse file tree 4 files changed +34
-1
lines changed
Expand file tree Collapse file tree 4 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ before_install:
104104 elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
105105 export CXX=clang++ CC=clang PYTHONHOME=$HOME/miniconda;
106106 fi
107+ - PYBIND11_VERSION=${PYBIND11_VERSION:-2.2.1}
107108
108109install :
109110 # Define the version of miniconda to download
@@ -126,8 +127,26 @@ install:
126127 - conda update -q conda
127128 # Useful for debugging any issues with conda
128129 - conda info -a
129- - conda install pytest numpy pybind11==2.2.1 -c conda-forge
130+ - conda install pytest numpy -c conda-forge
130131 - conda install cmake gtest -c conda-forge
132+ - |
133+ if [[ "$PYBIND11_VERSION" == "master" ]]; then
134+ conda_root=$(cd $(dirname $(which conda))/.. && pwd)
135+ mkdir -p $conda_root/tmp
136+ cd $conda_root/tmp
137+ curl -sSL -o pybind11.tar.gz https://github.com/pybind/pybind11/archive/master.tar.gz
138+ rm -rf pybind11-master
139+ tar xf pybind11.tar.gz
140+ cd pybind11-master
141+ python setup.py install
142+ mkdir -p build
143+ cd build
144+ cmake -DPYBIND11_TEST=OFF -DPYTHON_EXECUTABLE:FILEPATH=`which python` -DCMAKE_INSTALL_PREFIX=${conda_root} ..
145+ make install
146+ cd $TRAVIS_BUILD_DIR
147+ else
148+ conda install pybind11==${PYBIND11_VERSION} -c conda-forge
149+ fi
131150 - conda install xtensor==0.17.3 -c QuantStack
132151 - cmake -D BUILD_TESTS=ON -D CMAKE_INSTALL_PREFIX=$HOME/miniconda -D PYTHON_EXECUTABLE=$PY_EXE .
133152 - make -j2 test_xtensor_python
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ namespace pybind11
3131{
3232 namespace detail
3333 {
34+ #ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
3435 template <class T , xt::layout_type L>
3536 struct handle_type_name <xt::pyarray<T, L>>
3637 {
@@ -39,6 +40,7 @@ namespace pybind11
3940 return _ (" numpy.ndarray[" ) + npy_format_descriptor<T>::name () + _ (" ]" );
4041 }
4142 };
43+ #endif
4244
4345 template <typename T, xt::layout_type L>
4446 struct pyobject_caster <xt::pyarray<T, L>>
@@ -63,7 +65,11 @@ namespace pybind11
6365 return src.inc_ref ();
6466 }
6567
68+ #ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
6669 PYBIND11_TYPE_CASTER (type, handle_type_name<type>::name());
70+ #else
71+ PYBIND11_TYPE_CASTER (type, _(" numpy.ndarray[" ) + npy_format_descriptor<T>::name + _(" ]" ));
72+ #endif
6773 };
6874
6975 // Type caster for casting ndarray to xexpression<pyarray>
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ namespace pybind11
3232{
3333 namespace detail
3434 {
35+ #ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
3536 template <class T , std::size_t N, xt::layout_type L>
3637 struct handle_type_name <xt::pytensor<T, N, L>>
3738 {
@@ -40,6 +41,7 @@ namespace pybind11
4041 return _ (" numpy.ndarray[" ) + npy_format_descriptor<T>::name () + _ (" ]" );
4142 }
4243 };
44+ #endif
4345
4446 template <class T , std::size_t N, xt::layout_type L>
4547 struct pyobject_caster <xt::pytensor<T, N, L>>
@@ -65,7 +67,11 @@ namespace pybind11
6567 return src.inc_ref ();
6668 }
6769
70+ #ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
6871 PYBIND11_TYPE_CASTER (type, handle_type_name<type>::name());
72+ #else
73+ PYBIND11_TYPE_CASTER (type, _(" numpy.ndarray[" ) + npy_format_descriptor<T>::name + _(" ]" ));
74+ #endif
6975 };
7076
7177 // Type caster for casting ndarray to xexpression<pytensor>
Original file line number Diff line number Diff line change @@ -157,10 +157,12 @@ namespace pybind11
157157 return cast_impl (src, policy, parent);
158158 }
159159
160+ #ifdef PYBIND11_DESCR // The macro is removed from pybind11 since 2.3
160161 static PYBIND11_DESCR name ()
161162 {
162163 return _ (" xt::xtensor" );
163164 }
165+ #endif
164166
165167 template <typename T>
166168 using cast_op_type = cast_op_type<T>;
You can’t perform that action at this time.
0 commit comments