Menu

#401 swig 3 and python bindings

libSBML-5.11.0
closed
nobody
None
2015-06-12
2015-02-18
No

There are two issues which are interleaved. First is that parallel build (using cmake) seems to randomly update some of the files generated by swig. The tarball contains files generated with swig 2. In repeated builds, generated files are different. The result is that on a system with swig 3 installed, a mix of swig 2 and swig 3 generated files is used, which causes strange failures.

If all generated files are removed before build, they seem to be correctly regenerated. But this leads to the second problem, which is that when using swig 3, generated bindings for python are completely broken. All tests fail with NameError: args, because of the following function generated in src/bindings/python/libsbml.py (full file is attached):

    def appendAndOwn(self, item):
        if args[0] is not None: args[0].thisown = 0
        return _libsbml.ListOf_appendAndOwn(self, item)

What is the status here, is libsbml expected to work with swig 3?

Discussion

  • Frank Bergmann

    Frank Bergmann - 2015-02-18

    Hello, for the next version we have changed the way that the swig bindings will be created, so that they will be generated whenever a header file changes. I believe this will take care of the issue.

    we might also want to consider to no longer distribute the swig files. What with the many configuration options of libSBML, it seems no longer prudent to generate a set of files that most likely won't work.

    best
    Frank

     
  • Zbigniew Jędrzejewski-Szmek

    Yep, that would deal with the first part of the problem.

    Note that the code in question 'args[...].thisown = 0' comes from libsbml/src/bindings/python/local.i, which is part of libsbml itself.

     
  • Frank Bergmann

    Frank Bergmann - 2015-02-18

    Indeed, so what happened is that in the old version of swig, the signature for all the method wrappers wer like:

    def addChild(self, *args):
    

    with any numbers of arguments wrapped in the args array. Now with swig 3.0.5, the actual method args of the function are used:

    def addChild(self, child):
    

    the thing is, that we still need to find a way to take ownership of 'child' in this case rather than 'args[1]'. It will take a little while to sort that out.

    thanks for letting us know.
    Frank

     
  • Frank Bergmann

    Frank Bergmann - 2015-02-19

    Just to let you know, with revision r22020, this should be resolved in trunk, i no longer have any problems with the python bindings on F21 (with swig 3.0.5). This will be in the next release.

     
  • Sarah Keating

    Sarah Keating - 2015-06-12

    I'm calling this one resolved.

     
  • Sarah Keating

    Sarah Keating - 2015-06-12
    • status: open --> closed
    • Priority: -->
     

Log in to post a comment.