FS#36474 - [python-openbabel] Problems adding arbitrary attributes to objects. Swig flags problem.
Attached to Project:
Community Packages
Opened by Hector Mtz-Seara Monne (hseara) - Friday, 09 August 2013, 14:01 GMT
Last edited by Alexander F. Rødseth (xyproto) - Saturday, 24 August 2013, 19:24 GMT
Opened by Hector Mtz-Seara Monne (hseara) - Friday, 09 August 2013, 14:01 GMT
Last edited by Alexander F. Rødseth (xyproto) - Saturday, 24 August 2013, 19:24 GMT
|
Details
Description:
Right now openbabel python bindings have a bug that do not allow to add arbitrary attributes to objects. That renders it quite useless. The problem one might argue arise due to a bug in swig, see below. But clearly it is mainly a packaging problem easy to correct. As a general rule - packagers should use the same settings and options as upstream unless there is a good reason to do otherwise. In the case of Open Babel you can check what options are used when running swig in scripts/CMakeLists.txt, so the command should include these options: swig -python -c++ -small -O -templatereduce -naturalvar I don't know if Arch devs had any reason to use different ones (if they had, it should be documented in the build script), but this looks like a packaging bug. The package currently uses: swig -I../include/ -python -py3 -c++ openbabel-python.i only by adding the -O the problem will be solve: swig -O -I../include/ -python -py3 -c++ openbabel-python.i Another issue is in SWIG itself. I would not expect the behavior of the bindings to change because of not using optimization (-O). This command describes the flag: ~$ swig -python -help ... -O - Enable the following optimization options: -modern -fastdispatch -nosafecstrings -fvirtual -noproxydel -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone Arguably in both cases SWIG should generate code allowing to add arbitrary attributes to objects, but right now it doesn't. Probably _swig_getattr() and _swig_setattr() should be adjusted for it to first look for attribute in the Python class itself and only then try to look it up in c++ code. The reason is, because those functions are set as __getattr__ and __setattr__ methods in OBAtom class if flag -O is not used and that breaks setattr() in general case (breaks at least in case of properies). So until upstream, either openbabel or swig, solve the issue, please update the package so that the swiw call contain -O. This solve the issue. I have attached the corrected PKGBUILD. Additional info: * package version(s) community/python-openbabel 2.3.2-1 * config and/or log files etc. Steps to reproduce: |
This task depends upon
Closed by Alexander F. Rødseth (xyproto)
Saturday, 24 August 2013, 19:24 GMT
Reason for closing: Fixed
Saturday, 24 August 2013, 19:24 GMT
Reason for closing: Fixed
Comment by
Hector Mtz-Seara Monne (hseara) -
Saturday, 24 August 2013, 06:59 GMT
Comment by
Alexander F. Rødseth (xyproto) -
Saturday, 24 August 2013, 19:24 GMT
Could anybody take care about this issue? It is really straight
forward. The correct PKGBUILD is attached and the changes are
minimal: a "-O" when calling swig!!
Hi, thanks for reporting and for the solid bug report. Sorry for
the slight delay, the updated package will appear in [community]
shortly.