[Ns-developers] Status of Python bindings
Gustavo Carneiro
gjcarneiro at gmail.com
Sun May 4 14:10:05 PDT 2008
Hi all.
The current status of Python bindings for NS-3 is as follows.
We had a phone conference a couple of weeks ago to discuss the
pybindgen/ns-3 work.
Mathieu was concerned about:
1) complexity of pybindgen with (py)gccxml, and that I am the only
person that can understand it;
2) requiring developers to install gccxml from CVS (since the gccxml
maintainers have not made an official release in a very long time), is bad;
3) pybindgen, even without gccxml involved, was poorly documented, at
best.
We discussed the possibility of using boost::python instead, but only people
skilled in C++ template programming, such as Mathieu, can grok the
associated compiler error messages. Another alternative discussed was SWIG,
but I dismissed it as generating too ugly and inefficient code.
Finally we discussed ways to improve on the current pybindgen solution.
Participants were under the impression that, if you take away the gccxml
layer, the python scripts calling pybindgen API directly were simple enough
and maintainable. This was subject to confirmation. Mathieu even
maintained the position that it is better to completely forget gccxml and
simply maintain the API definition script by hand. I, on the other hand,
believe this is not maintainable in the long run, and hand writing API
definitions will lead to Python bindings always being one step behind and
always feeling like a 2nd class citizen.
[ please correct anything above I recall wrong from the phone conference ]
As I result of these discussions, I started work on a new pybindgen mode
that uses gccxml but which generates a python script which would generate
the C++ module, instead of directly generating the module. This work needs
time and patience, and is being developed on a separate pybindgen branch,
see
https://code.launchpad.net/~gjc/pybindgen/gccxml-to-python
The work is not yet complete, but is well advanced (75% at least, I would
say). In attachment you can find a ns3 module generation script produced by
this branch. Developers should be able to judge the suitability of this API
for maintaining bindings, although bearing in mind that some things can
still be (slightly) improved.
I am sure not every one agrees, but my "vision" for the bindings would be:
1. Add the pybindgen to ns-3 tree via an automated branch checkout, like we
do for regression traces (so that installation of PBG is not required);
2. Once in a while, a developer does something like ./waf --scan-bindings,
which calls pybindgen in gccxml mode, and outputs a ns3module_generated.py
file (or several files, one per module, if the generated file ends up being
large)
3. The generated files are added to the ns-3 repository;
4. The bindings generation script reads the autoscanned definitions plus a
ns3module_local.py file which can contain user customizations and extra
definitions for new API.
I think that's it. Details left to be figured out, of course.
Comments are welcome.
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ns3modulegen-generated.py.bz2
Type: application/x-bzip2
Size: 15523 bytes
Desc: not available
Url : http://mailman.isi.edu/pipermail/ns-developers/attachments/20080504/4feaf306/ns3modulegen-generated.py.bin
More information about the Ns-developers
mailing list