welterde / sbigpy

Python binding to SBIG universal driver
0 stars 0 forks source link

Considering ctypes? #1

Open phsilva opened 10 years ago

phsilva commented 10 years ago

@welterde, I am Paulo from chimera project. I took a look here and as I already went this way with my own wrapper for SBIG Udrv, i was wondering if you would consider help me port this wrapper (or mine) to use ctypes instead of SWIG.

ctypes provides great flexibility as there is no need to provide binaries besides the SBIG library itself. Given the very easy API SBIG provides it would be a doable task.

I am considering doing that and migrating chimera sbig dirver to use it.

My original wrapper is here https://pypi.python.org/pypi/python-sbigudrv

welterde commented 10 years ago

I had considered ctypes at first, but the large number of structs one has to reimplement (unless I was using ctypes wrong.. certainly possible) made me switch to SWIG.

Or do you know of some way of automating this task (similar to what SWIG does - well.. one can certainly write a C parser or something like that..)?

welterde commented 10 years ago

Ok.. There are already some generators in existence.. so I guess we can give that a shot (should also be more stable than my swig wrapper).

phsilva commented 10 years ago

I was considering writing a small tool to automate it. While it might not be worth the tool for this small project I think it might be useful for future jobs as well.

I will prototype something and let you know. Good to know you might consider it, I don't think we need two SBIG wrapper for Python, having a single ctypes based would be great for deployment.

which tools did you find?

welterde commented 10 years ago

https://github.com/albertz/PyCParser lists a few. I just gave ctypesgen a spin and it appears to generate to something more or less sensible.

phsilva commented 10 years ago

Great, I will check it.

This looks like what I would try as well https://github.com/clchiou/ctypes-binding-generator, a real compiler behind it (clang).