[ascend] Fixed Python code after SWIG update (>= 3.0.3) (bz#1196699)

Antonio Trande sagitter at fedoraproject.org
Thu Feb 26 16:03:44 UTC 2015


commit 2505f44d5ec964db2aaafc3325dd0220ce587903
Author: sagitter <sagitter at fedoraproject.org>
Date:   Thu Feb 26 17:03:32 2015 +0100

    Fixed Python code after SWIG update (>= 3.0.3) (bz#1196699)

 ascend-fix_pythoncode_blocks.patch | 287 +++++++++++++++++++++++++++++++++++++
 ascend.spec                        |  16 ++-
 2 files changed, 300 insertions(+), 3 deletions(-)
---
diff --git a/ascend-fix_pythoncode_blocks.patch b/ascend-fix_pythoncode_blocks.patch
new file mode 100644
index 0000000..5f9c7cd
--- /dev/null
+++ b/ascend-fix_pythoncode_blocks.patch
@@ -0,0 +1,287 @@
+diff -up ascxx/ascpy.i.orig ascxx/ascpy.i
+--- ascxx/ascpy.i.orig	2015-02-26 13:38:53.147957858 +0100
++++ ascxx/ascpy.i	2015-02-26 14:20:08.532213467 +0100
+@@ -62,12 +62,12 @@ extern "C"{
+ }
+ 
+ // Import the preferences module
+-%pythoncode {
++%pythoncode %{
+ 	import preferences;
+-}
++%}
+ 
+ // Set-valued instance variable
+-%pythoncode {
++%pythoncode %{
+ 	class SetIter:
+ 		def __init__(self,set):
+ 			self.set=set
+@@ -77,7 +77,7 @@ extern "C"{
+ 				raise StopIteration
+ 			self.index = self.index + 1
+ 			return self.set[self.index]
+-}
++%}
+ 
+ template<class T>
+ class ASCXX_Set{
+@@ -88,20 +88,20 @@ public:
+ 	const unsigned long	length() const;
+ };
+ %extend ASCXX_Set<long>{
+-	%pythoncode {
++	%pythoncode %{
+ 		def __getitem__(self, index):
+ 			return self.at(index)
+ 		def __iter__(self):
+ 			return SetIter(self)
+-	}
++	%}
+ }
+ %extend ASCXX_Set<SymChar>{
+-	%pythoncode {
++	%pythoncode %{
+ 		def __getitem__(self, index):
+ 			return self.at(index)
+ 		def __iter__(self):
+ 			return SetIter(self)
+-	}
++	%}
+ }
+ 
+ 
+@@ -177,7 +177,7 @@ class UnitsM;
+ %include "units.h"
+ 
+ %extend UnitsM{
+-	%pythoncode{
++	%pythoncode%{
+ 		def getConvertedValue(self,si_value):
+ 			"""Return an SI value converted to self's units of measurement."""
+ 			_v = si_value / self.getConversion()
+@@ -189,7 +189,7 @@ class UnitsM;
+ 				return _s
+ 			else:
+ 				return _s + " " + _n;
+-	}
++	%}
+ }
+ 
+ /*
+@@ -201,7 +201,7 @@ class UnitsM;
+ %rename(__str__) Dimensions::toString;
+ 
+ %extend Dimensions{
+-	%pythoncode {
++	%pythoncode %{
+ 		
+ 		def __str__(self):
+ 			return self.toString()
+@@ -245,7 +245,7 @@ class UnitsM;
+ 
+ 			return Units(str)
+ 
+-	}
++	%}
+ }
+ 
+ /*
+@@ -308,7 +308,7 @@ public:
+ 		return self->getName().toString();
+ 	}
+ 
+-	%pythoncode{
++	%pythoncode %{
+ 		def getPreferredUnits(self):
+ 			"""Return preferred units for an instance, which is done by lookup per atom type."""
+ 			if not self.isRefinedReal():
+@@ -327,7 +327,7 @@ public:
+ 				return None
+ 
+ 			return _units;
+-	}
++	%}
+ }
+ 
+ typedef enum{
+@@ -429,7 +429,7 @@ public:
+ 		}
+ 	}
+ 		
+-	%pythoncode {
++	%pythoncode %{
+ 		def getSetValue(self):
+ 			"""Return the value of a set, as a integer or string Python sequence."""
+ 			if self.isSetInt():
+@@ -528,7 +528,7 @@ public:
+ 		def __radd__(self,other):
+ 			a,b = self.__coerce__(other)
+ 			return b + a
+-	}
++	%}
+ }
+ 
+ /*
+diff -up ascxx/plot.i.orig ascxx/plot.i
+--- ascxx/plot.i.orig	2015-02-26 14:18:10.085626995 +0100
++++ ascxx/plot.i	2015-02-26 14:18:38.285008558 +0100
+@@ -7,7 +7,7 @@ SWIG interface for plotting from ASCEND
+ %include "plot.h"
+ 
+ %extend Plot{
+-	%pythoncode{
++	%pythoncode%{
+ 		def show(self,mainloop=True):
+ 			import loading
+ 			loading.load_matplotlib(throw=True)
+@@ -55,6 +55,6 @@ SWIG interface for plotting from ASCEND
+ 			# if self.getXLow() and self.getXHigh():
+ 			#	matplotlib.gca().set_xlim([self.getXLow(), self.getXHigh()])
+ 			# */
+-	}
++	%}
+ }
+ 
+diff -up ascxx/solver.i.orig ascxx/solver.i
+--- ascxx/solver.i.orig	2015-02-26 14:20:30.537507265 +0100
++++ ascxx/solver.i	2015-02-26 14:22:33.891154186 +0100
+@@ -21,9 +21,9 @@
+ #include "matrix.h"
+ %}
+ 
+-%pythoncode{
++%pythoncode%{
+ 	import types
+-}
++%}
+ 
+ %typemap(in) FILE * {
+ %#if defined(__MINGW32__) && !defined(HAVE_MSVCR71)
+@@ -50,7 +50,7 @@
+ 	Instanc __getattr__(const char *name){
+ 		return self->getModel().getChild(SymChar(name));
+ 	}
+-	%pythoncode{
++	%pythoncode%{
+ 		def setParameter(self,name,value):
+ 			""" set the value of a parameter for this integrator """
+ 			P = self.getParameters()
+@@ -63,13 +63,13 @@
+ 				if p.getName()==name:
+ 					return p.getValue()
+ 			raise KeyError
+-	}
++	%}
+ }
+ 
+ %include "matrix.h"
+ 
+ // SOLVER PARAMETERS
+-%pythoncode{
++%pythoncode%{
+ 	class SolverParameterIter:
+ 		def __init__(self, params):
+ 			self.params = params;
+@@ -84,7 +84,7 @@
+ 			p = self.params.getParameter(self.index)
+ 			self.index = self.index +1
+ 			return p
+-}
++%}
+ 
+ class SolverParameters{
+ public:
+@@ -95,7 +95,7 @@ public:
+ };
+ 
+ %extend SolverParameters{
+-	%pythoncode{
++	%pythoncode%{
+ 		def __iter__(self):
+ 			return SolverParameterIter(self)
+ 		def __getattr(self,index):
+@@ -120,7 +120,7 @@ public:
+ 					p.setValue(value)
+ 					return
+ 			raise KeyError
+-	}
++	%}
+ }
+ 
+ class SolverParameter{
+@@ -165,7 +165,7 @@ public:
+ };
+ 
+ %extend SolverParameter{
+-	%pythoncode{
++	%pythoncode%{
+ 		def __str__(self):
+ 			if self.isInt(): return "%s = %d" %(self.getName(),self.getIntValue())
+ 			if self.isBool(): return "%s = %s" %(self.getName(),self.getBoolValue())
+@@ -192,17 +192,17 @@ public:
+ 				self.setStrValue(value)
+ 				return
+ 			raise TypeError
+-	}
++	%}
+ }
+ 
+ %template(IncidencePointVector) std::vector<IncidencePoint>;
+ %include "incidencematrix.h"
+ 
+ %extend IncidencePoint{
+-	%pythoncode{
++	%pythoncode%{
+ 		def __repr__(self):
+ 			return str([ self.row, self.col, int(self.type) ]);
+-	}
++	%}
+ }
+ 
+ /* Variables and relations belong to solvers, so they're here: */
+@@ -210,10 +210,10 @@ public:
+ %include "variable.h"
+ 
+ %extend Variable {
+-	%pythoncode{
++	%pythoncode%{
+ 		def __repr__(self):
+ 			return self.getName()
+-	}
++	%}
+ }
+ 
+ //%include "relation.h"
+@@ -229,10 +229,10 @@ public:
+ };
+ 
+ %extend Relation {
+-	%pythoncode{
++	%pythoncode%{
+ 		def __repr__(self):
+ 			return self.getName()
+-	}
++	%}
+ }
+ 
+ %template(VariableVector) std::vector<Variable>;
+@@ -289,7 +289,7 @@ public:
+ /* findIndependentVar has changed to return void, throw exception */
+ 
+ %extend Integrator{
+-	%pythoncode{
++	%pythoncode%{
+ 		def setParameter(self,name,value):
+ 			""" set the value of a parameter for this integrator """
+ 			P = self.getParameters()
+@@ -302,7 +302,7 @@ public:
+ 				if p.getName()==name:
+ 					return p.getValue()
+ 			raise KeyError
+-	}
++	%}
+ }
+ 
+ %feature("director") IntegratorReporterCxx;
+
diff --git a/ascend.spec b/ascend.spec
index e375989..00e0e2d 100644
--- a/ascend.spec
+++ b/ascend.spec
@@ -12,7 +12,7 @@
 Name:		ascend
 Summary:	ASCEND modelling environment
 Version:	0.9.8
-Release:	15.20140710svn4695%{?dist}
+Release:	16.20140710svn4695%{?dist}
 License:	GPLv2+
 URL:		http://ascend4.org/
 
@@ -32,7 +32,10 @@ Patch2:  %{name}-libpaths.patch
 
 ##This patch is needed to compile IDA solver with sundials-2.5.0
 ##http://bugs.ascend4.org/view.php?id=559
-Patch3:  %{name}-idasolver.patch 
+Patch3:  %{name}-idasolver.patch
+
+##Fix python-code blocks (bz#1196699)
+Patch4:  %{name}-fix_pythoncode_blocks.patch
 
 
 #------ build dependencies -------
@@ -135,6 +138,9 @@ Files have 5 extensions:
 %patch1 -p0
 %patch2 -p0
 %patch3 -p0
+%if 0%{?fedora} >= 21
+%patch4 -p0
+%endif
 
 sed -e 's|@@lib@@|%{_lib}|g' -i SConstruct
 sed -e 's|@@libdir@@|%{_libdir}|g' -i SConstruct
@@ -261,7 +267,8 @@ fi
 gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 
 %files
-%doc LICENSE.txt CHANGELOG.txt
+%license LICENSE.txt 
+%doc CHANGELOG.txt
 %{_bindir}/%{name}
 %dir %{johnpye}/fprops/test
 %{johnpye}/fprops/test/ph
@@ -389,6 +396,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 #%%doc doc/book.pdf
 
 %changelog
+* Thu Feb 26 2015 Antonio Trande <sagitter at fedoraproject.org> 0.9.8-16.20140710svn4695
+- Fixed Python code after SWIG update (>= 3.0.3) (bz#1196699)
+
 * Fri Sep 05 2014 Antonio Trande <sagitter at fedoraproject.org> 0.9.8-15.20140710svn4695
 - Changed Ipopt and MUMPS minimal requests
 


More information about the scm-commits mailing list