# HG changeset patch # User Chris Cannam # Date 1458061118 0 # Node ID 049de1137eab06717b96f5d7a93b4efaff2a9c32 # Parent 2a9fb03458d74565845654aff6a0f2b8dc677248 Patch from Simon Black for NumPy >1.9 compatibility diff -r 2a9fb03458d7 -r 049de1137eab vampy-main.cpp --- a/vampy-main.cpp Tue Nov 25 09:58:08 2014 +0000 +++ b/vampy-main.cpp Tue Mar 15 16:58:38 2016 +0000 @@ -30,9 +30,13 @@ // define this symbol if you use another version of numpy in the makefile // Vampy will not attempt to load a lower version than specified #ifdef HAVE_NUMPY -#ifndef NUMPY_SHORTVERSION -#define NUMPY_SHORTVERSION 1.9 +#ifndef NUMPY_MAJORVERSION +#define NUMPY_MAJORVERSION 1 #endif +#ifndef NUMPY_MINORVERSION +#define NUMPY_MINORVERSION 9 +#endif + #endif #include "vamp/vamp.h" @@ -117,13 +121,13 @@ #ifdef HAVE_NUMPY - string ver; + string ver, majorver, minorver; std::istringstream verStream; - float numpyVersion; + int numpyVersionMajor, numpyVersionMinor; /// attmept to test numpy version before importing the array API DSTREAM << "Numpy build information: ABI level: " << NPY_VERSION - << " Numpy version: " << NUMPY_SHORTVERSION << endl; + << " Numpy version: " << NUMPY_MAJORVERSION << "." << NUMPY_MINORVERSION << endl; PyObject *pyModule, *pyDict, *pyVer; @@ -150,14 +154,21 @@ ver = PyString_AsString(pyVer); ver = ver.substr(0,ver.rfind(".")); + majorver = ver.substr(0,ver.rfind(".")); + minorver = ver.substr(ver.rfind(".")+1); + + // parse version string to float + verStream.str(majorver); + verStream >> numpyVersionMajor; + verStream.str(minorver); + verStream >> numpyVersionMinor; - // parse version string to float - verStream.str(ver); - verStream >> numpyVersion; - - DSTREAM << "Numpy runtime version: " << numpyVersion << endl; - if (numpyVersion < (float) NUMPY_SHORTVERSION) { - cerr << "ERROR: Incompatible Numpy version found: " << numpyVersion << endl; + DSTREAM << "Numpy runtime version: " << numpyVersionMajor << "." << numpyVersionMinor << endl; + + if(numpyVersionMajor < NUMPY_MAJORVERSION || + (numpyVersionMajor < NUMPY_MAJORVERSION && + numpyVersionMinor < NUMPY_MINORVERSION)) { + cerr << "ERROR: Incompatible Numpy version found: " << ver << endl; goto numpyFailure; } @@ -180,7 +191,7 @@ numpyFailure: - cerr << "Please make sure you have Numpy " << NUMPY_SHORTVERSION << " or greater installed." << endl; + cerr << "Please make sure you have Numpy " << NUMPY_MAJORVERSION << "." << NUMPY_MINORVERSION << " or greater installed." << endl; cerr << "Vampy: Numpy support disabled." << endl; numpyInstalled = false; arrayApiInitialised = true;