diff --git a/src/details.hpp b/src/details.hpp
index 05f1308f47d30d422992ab3bd469346c2f8452d5..949ed0c21e7369b86f1cbafc17305024990a9aeb 100644
--- a/src/details.hpp
+++ b/src/details.hpp
@@ -20,6 +20,11 @@
 #include <boost/python.hpp>
 #include <Eigen/Core>
 
+#include <numpy/numpyconfig.h>
+#ifdef NPY_1_8_API_VERSION
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#endif
+
 #include <numpy/arrayobject.h>
 #include <iostream>
 
diff --git a/src/fwd.hpp b/src/fwd.hpp
index f601a7c318b6c5193cc709b0e99f17301eba0734..378046ed5cc89d6cc5dccdb6ac1c8e069dd0a59e 100644
--- a/src/fwd.hpp
+++ b/src/fwd.hpp
@@ -19,7 +19,10 @@
 
 #include <boost/python.hpp>
 #include <Eigen/Core>
+
+#ifdef NPY_1_8_API_VERSION
 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#endif
 
 namespace eigenpy
 {