yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #02373
[Branch ~yade-dev/yade/trunk] Rev 1822: 1. Re-enable PeriodicPythonEngine and a few other YADE_REQUIRE_FEATURE(PYTHON) that I overlooked
------------------------------------------------------------
revno: 1822
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Sun 2009-11-29 16:46:19 +0100
message:
1. Re-enable PeriodicPythonEngine and a few other YADE_REQUIRE_FEATURE(PYTHON) that I overlooked
2. Make the python main program work with plugins (RTLD_GLOBAL in both DynLibManager and python); doesn't work with openmp and opengl (investigation ongoing), looks promising otherwise. The program is called yade-trunk-dbg-py and such; not all options of the c++ main is implemented (yet?).
3. (In previous commit) Remove loading preferences.xml, just use QtGUI if possible and enabled, otherwise "only" python console.
modified:
core/main/main.py
core/main/pyboot.cpp
examples/concrete/uniax.py
lib/factory/DynLibManager.cpp
pkg/common/Engine/StandAloneEngine/PeriodicPythonRunner.cpp
pkg/common/Engine/StandAloneEngine/PhysicalActionContainerReseter.cpp
pkg/common/Engine/StandAloneEngine/ResetRandomPosition.cpp
pkg/common/Engine/StandAloneEngine/SpheresFactory.cpp
py/yadeWrapper/yadeWrapper.cpp
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription.
=== modified file 'core/main/main.py'
--- core/main/main.py 2009-11-29 11:03:25 +0000
+++ core/main/main.py 2009-11-29 15:46:19 +0000
@@ -1,6 +1,15 @@
#!/usr/bin/python
# syntax:python
+# see file:///usr/share/doc/python2.6/html/library/sys.html#sys.setdlopenflags
+# and various web posts on the topic, e.g.
+# * http://gcc.gnu.org/faq.html#dso
+# * http://www.code-muse.com/blog/?p=58
+# * http://wiki.python.org/moin/boost.python/CrossExtensionModuleDependencies
+import sys, DLFCN
+sys.setdlopenflags(DLFCN.RTLD_NOW | DLFCN.RTLD_GLOBAL)
+
+
# find what is our version, based on argv[0]
import sys,re,os.path
m=re.match('(.*)/bin/yade(-.*)-py',sys.argv[0])
=== modified file 'core/main/pyboot.cpp'
--- core/main/pyboot.cpp 2009-11-29 11:03:25 +0000
+++ core/main/pyboot.cpp 2009-11-29 15:46:19 +0000
@@ -36,25 +36,17 @@
log4cxx::LoggerPtr localLogger=log4cxx::Logger::getLogger("yade");
localLogger->setLevel(getenv("YADE_DEBUG")?debugLevel:warnLevel);
#endif
- // create singletons
- Omega::instance();
- ClassFactory::instance();
- SerializableSingleton::instance();
+
+ #if defined(YADE_OPENMP) || defined(YADE_OPENGL)
+ LOG_ERROR("Yade compiled with openmp/opengl. Using python main will likely crash as soone as an ostream is used.")
+ #endif
PyEval_InitThreads();
- int _i=0;
- #define TR fprintf(stderr,"%d",_i++)
- TR;
Omega& O(Omega::instance());
- TR;
O.init();
O.origArgv=NULL; O.origArgc=0;
-
- fprintf(stderr,"rootBody=%p\n",O.getRootBody().get());
- TR;
O.initTemps();
- TR;
#ifdef YADE_DEBUG
if(gdb){
ofstream gdbBatch;
@@ -64,15 +56,14 @@
signal(SIGSEGV,crashHandler);
}
#endif
- TR;
- TR;
vector<string> dd2; for(int i=0; i<python::len(dd); i++) dd2.push_back(python::extract<string>(dd[i]));
Omega::instance().scanPlugins(dd2);
- TR;
}
void yadeFinalize(){ Omega::instance().cleanupTemps(); }
BOOST_PYTHON_MODULE(boot){
+ // FIXME: still a crasher with openmp or OpenGL...
+ // cerr<<"[boot]"<<endl;
python::scope().attr("initialize")=&yadeInitialize;
python::scope().attr("finalize")=&yadeFinalize; //,"Finalize yade (only to be used internally).")
}
=== modified file 'examples/concrete/uniax.py'
--- examples/concrete/uniax.py 2009-11-24 17:03:29 +0000
+++ examples/concrete/uniax.py 2009-11-29 15:46:19 +0000
@@ -91,7 +91,7 @@
PeriodicPythonRunner(virtPeriod=3e-5/strainRateTension,realLim=5,command='addPlotData()',label='plotDataCollector'),
PeriodicPythonRunner(realPeriod=4,command='stopIfDamaged()',label='damageChecker'),
]
-O.miscParams=[GLDrawCpmPhys(dmgLabel=False,colorStrain=False,epsNLabel=False,epsT=False,epsTAxes=False,normal=False,contactLine=True)]
+#O.miscParams=[GLDrawCpmPhys(dmgLabel=False,colorStrain=False,epsNLabel=False,epsT=False,epsTAxes=False,normal=False,contactLine=True)]
# plot stresses in ¼, ½ and ¾ if desired as well; too crowded in the graph that includes confinement, though
plot.plots={'eps':('sigma',)} #'sigma.25','sigma.50','sigma.75')}
=== modified file 'lib/factory/DynLibManager.cpp'
--- lib/factory/DynLibManager.cpp 2009-08-19 10:48:06 +0000
+++ lib/factory/DynLibManager.cpp 2009-11-29 15:46:19 +0000
@@ -39,7 +39,7 @@
// load plugin with given filename
bool DynLibManager::load (const string& lib){
if (lib.empty()) throw std::runtime_error(__FILE__ ": got empty library name to load.");
- void* handle = dlopen(lib.c_str(),RTLD_NOW);
+ void* handle = dlopen(lib.c_str(),RTLD_GLOBAL | RTLD_NOW);
if (!handle) return !error();
handles[lib] = handle;
return true;
=== modified file 'pkg/common/Engine/StandAloneEngine/PeriodicPythonRunner.cpp'
--- pkg/common/Engine/StandAloneEngine/PeriodicPythonRunner.cpp 2009-11-21 16:46:58 +0000
+++ pkg/common/Engine/StandAloneEngine/PeriodicPythonRunner.cpp 2009-11-29 15:46:19 +0000
@@ -1,3 +1,2 @@
#include<yade/pkg-common/PeriodicPythonRunner.hpp>
YADE_PLUGIN((PeriodicPythonRunner));
-YADE_REQUIRE_FEATURE(PYTHON)
=== modified file 'pkg/common/Engine/StandAloneEngine/PhysicalActionContainerReseter.cpp'
--- pkg/common/Engine/StandAloneEngine/PhysicalActionContainerReseter.cpp 2009-11-21 16:46:58 +0000
+++ pkg/common/Engine/StandAloneEngine/PhysicalActionContainerReseter.cpp 2009-11-29 15:46:19 +0000
@@ -10,6 +10,7 @@
#include<yade/core/MetaBody.hpp>
YADE_PLUGIN((PhysicalActionContainerReseter)(BexResetter));
+
PhysicalActionContainerReseter::PhysicalActionContainerReseter(){}
PhysicalActionContainerReseter::~PhysicalActionContainerReseter(){}
void PhysicalActionContainerReseter::action(MetaBody* ncb){ ncb->bex.reset(); }
=== modified file 'pkg/common/Engine/StandAloneEngine/ResetRandomPosition.cpp'
--- pkg/common/Engine/StandAloneEngine/ResetRandomPosition.cpp 2009-11-25 21:21:17 +0000
+++ pkg/common/Engine/StandAloneEngine/ResetRandomPosition.cpp 2009-11-29 15:46:19 +0000
@@ -17,7 +17,6 @@
#include<sstream>
YADE_PLUGIN((ResetRandomPosition));
-YADE_REQUIRE_FEATURE(PYTHON)
CREATE_LOGGER(ResetRandomPosition);
boost::variate_generator<boost::mt19937,boost::uniform_real<> >
=== modified file 'pkg/common/Engine/StandAloneEngine/SpheresFactory.cpp'
--- pkg/common/Engine/StandAloneEngine/SpheresFactory.cpp 2009-11-25 21:21:17 +0000
+++ pkg/common/Engine/StandAloneEngine/SpheresFactory.cpp 2009-11-29 15:46:19 +0000
@@ -20,7 +20,6 @@
#include<sstream>
YADE_PLUGIN((SpheresFactory));
-YADE_REQUIRE_FEATURE(PYTHON)
CREATE_LOGGER(SpheresFactory);
boost::variate_generator<boost::mt19937,boost::uniform_real<> >
=== modified file 'py/yadeWrapper/yadeWrapper.cpp'
--- py/yadeWrapper/yadeWrapper.cpp 2009-11-29 11:03:25 +0000
+++ py/yadeWrapper/yadeWrapper.cpp 2009-11-29 15:46:19 +0000
@@ -305,7 +305,6 @@
OMEGA.init();
rb=OMEGA.getRootBody();
}
- fprintf(stderr,"rootBody = %p",rb.get());
assert(rb);
// if(!rb->physicalParameters){rb->physicalParameters=shared_ptr<PhysicalParameters>(new ParticleParameters);} /* PhysicalParameters crashes StateMetaEngine... why? */
if(!rb->boundingVolume){rb->boundingVolume=shared_ptr<AABB>(new AABB);}
@@ -590,8 +589,10 @@
shared_ptr<T> instance;
if(clss.empty()){ instance=shared_ptr<T>(new T); }
else{
- instance=dynamic_pointer_cast<T>(ClassFactory::instance().createShared(clss));
- if(!instance) throw runtime_error("Invalid class `"+clss+"': either nonexistent, or unable to cast to type `"+typeid(T).name()+"'");
+ shared_ptr<Factorable> instance0=ClassFactory::instance().createShared(clss);
+ if(!instance0) throw runtime_error("Invalid class `"+clss+"' (not created by ClassFactory).");
+ instance=dynamic_pointer_cast<T>(instance0);
+ if(!instance) throw runtime_error("Invalid class `"+clss+"' (unable to cast to typeid `"+typeid(T).name()+"')");
}
Serializable_updateAttrs(instance,d);
return instance;