Add -python patch to adapt to changed boost python interface.

This commit is contained in:
Jerry James 2018-02-14 21:32:47 -07:00
parent 9bc0dc363c
commit 88e2e511c8
2 changed files with 143 additions and 10 deletions

133
Singular-python.patch Normal file
View File

@ -0,0 +1,133 @@
diff -up singular-4.1.0/Singular/dyn_modules/python/interpreter_support.cc.orig singular-4.1.0/Singular/dyn_modules/python/interpreter_support.cc
--- singular-4.1.0/Singular/dyn_modules/python/interpreter_support.cc.orig 2017-04-12 09:54:29.000000000 -0600
+++ singular-4.1.0/Singular/dyn_modules/python/interpreter_support.cc 2018-02-14 21:16:46.138812306 -0700
@@ -2,6 +2,7 @@
#ifdef HAVE_PYTHON_MOD
#include <sstream>
#include <boost/python.hpp>
+#include <boost/python/numpy.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include "Singular/subexpr.h"
#include "Poly.h"
@@ -20,7 +21,7 @@
#include "poly_wrap.h"
extern int inerror;
using namespace boost::python;
-using boost::python::numeric::array;
+using boost::python::numpy::ndarray;
using boost::python::extract;
static void free_leftv(leftv args)
{
@@ -28,7 +29,7 @@ static void free_leftv(leftv args)
omFreeBin(args, sleftv_bin);
}
-matrix matrixFromArray(const boost::python::numeric::array& f)
+matrix matrixFromArray(const boost::python::numpy::ndarray& f)
{
object o=f.attr("shape");
object o1=o[0];
@@ -130,7 +131,7 @@ class arg_list
v->rtyp=VECTOR_CMD;
internal_append(v);
}
- void appendArray(const boost::python::numeric::array& f)
+ void appendArray(const boost::python::numpy::ndarray& f)
{
leftv v=initArg();
matrix m=matrixFromArray(f);
@@ -276,7 +277,7 @@ class idhdl_wrap
id->data.p=p.as_poly();
}
}
- void writeArray(const boost::python::numeric::array& f)
+ void writeArray(const boost::python::numpy::ndarray& f)
{
if(id->typ=MATRIX_CMD)
{
@@ -323,9 +324,9 @@ class idhdl_wrap
};
-static boost::python::numeric::array buildPythonMatrix(matrix m, ring r)
+static boost::python::numpy::ndarray buildPythonMatrix(matrix m, ring r)
{
- using boost::python::numeric::array;
+ using boost::python::numpy::ndarray;
using boost::python::self;
using boost::python::make_tuple;
using boost::python::tuple;
@@ -345,11 +346,7 @@ static boost::python::numeric::array bui
}
l.append(row);
}
- //FIXME: should call this only once
- boost::python::numeric::array::set_module_and_type("Numeric",
- "ArrayType"
- );
- return boost::python::numeric::array(l);
+ return boost::python::numpy::array(l);
}
boost::python::object buildPyObjectFromLeftv(leftv v);
boost::python::list buildPythonList(lists l, ring r)
diff -up singular-4.1.0/Singular/dyn_modules/python/playground.cc.orig singular-4.1.0/Singular/dyn_modules/python/playground.cc
--- singular-4.1.0/Singular/dyn_modules/python/playground.cc.orig 2017-04-12 09:54:29.000000000 -0600
+++ singular-4.1.0/Singular/dyn_modules/python/playground.cc 2018-02-14 20:28:55.954897109 -0700
@@ -2,8 +2,8 @@
#ifdef HAVE_PYTHON_MOD
#include <boost/python.hpp>
#include "Poly.h"
-#include "boost/python/numeric.hpp"
-using boost::python::numeric::array;
+#include "boost/python/numpy.hpp"
+using boost::python::numpy::ndarray;
using boost::python::self;
using boost::python::make_tuple;
using boost::python::tuple;
@@ -24,13 +24,10 @@ object foo()
}
l.append(row);
}
- boost::python::numeric::array::set_module_and_type("Numeric",
- "ArrayType"
- );
- boost::python::numeric::array a(l);
+ boost::python::numpy::ndarray a(l);
return a;
}
-object foo2(array f)
+object foo2(ndarray f)
{
using boost::python::extract;
object o=f.attr("shape");
diff -up singular-4.1.0/Singular/dyn_modules/python/python_module.cc.orig singular-4.1.0/Singular/dyn_modules/python/python_module.cc
--- singular-4.1.0/Singular/dyn_modules/python/python_module.cc.orig 2017-04-12 09:54:29.000000000 -0600
+++ singular-4.1.0/Singular/dyn_modules/python/python_module.cc 2018-02-14 20:30:26.498656892 -0700
@@ -72,6 +72,7 @@ extern "C" int SI_MOD_INIT(python_module
setenv("PYTHONPATH",buf,1);
Py_Initialize();
+ boost::python::numpy::initialize();
PyRun_SimpleString("from sys import path\n\
path.insert(0,'.')\n");
initSingular();
diff -up singular-4.1.0/Singular/dyn_modules/python/wrapper.h.orig singular-4.1.0/Singular/dyn_modules/python/wrapper.h
--- singular-4.1.0/Singular/dyn_modules/python/wrapper.h.orig 2017-04-12 09:54:29.000000000 -0600
+++ singular-4.1.0/Singular/dyn_modules/python/wrapper.h 2018-02-14 20:57:54.557934662 -0700
@@ -2,6 +2,7 @@
#define PYTHON_SINGULAR_WRAPPER_HEADER
#include <Python.h>
#include <boost/python.hpp>
+#include <boost/python/numpy.hpp>
#include <sstream>
#include <kernel/mod2.h>
@@ -24,7 +25,7 @@
#include "interpreter_support.h"
#include "ring_wrap.h"
#include "intvec_wrap.h"
-using boost::python::numeric::array;
+using boost::python::numpy::ndarray;
using boost::python::extract;
using namespace boost::python;

View File

@ -86,6 +86,8 @@ Patch8: %{name}-polymake.patch
Patch9: %{name}-emacs.patch
# Revert a change to static function in p3 due to sagemath requiring it
Patch10: %{name}-sagemath.patch
# Adapt to changed python interface in boost 1.65
Patch11: %{name}-python.patch
%description
Singular is a computer algebra system for polynomial computations, with
@ -220,6 +222,7 @@ This package contains the Singular java interface.
%patch8 -p1 -b .polymake
%patch9 -p1 -b .emacs
%patch10 -p1 -b .sagemath
%patch11 -p1 -b .python
# Fix the name of the boost_python library
sed -ri 's/(lboost_python)-\$\{PYTHON_VERSION\}/\1/' \
@ -356,17 +359,11 @@ if [ $1 = 0 ]; then
/sbin/install-info --delete %{_infodir}/singular.hlp %{_infodir}/dir 2>/dev/null || :
fi
%post -n factory -p /sbin/ldconfig
%postun -n factory -p /sbin/ldconfig
%post -n gfanlib -p /sbin/ldconfig
%postun -n gfanlib -p /sbin/ldconfig
%post libpolys -p /sbin/ldconfig
%postun libpolys -p /sbin/ldconfig
%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig
%ldconfig_scriptlets -n factory
%ldconfig_scriptlets -n gfanlib
%ldconfig_scriptlets libpolys
%ldconfig_scriptlets libs
%files
@ -482,6 +479,9 @@ fi
%changelog
* Wed Feb 14 2018 Jerry James <loganjerry@gmail.com> - 4.1.0p3-8
- Add -python patch to adapt to changed boost python interface
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.1.0p3-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild