Python for SMILE

The engine.
Post Reply
Gardiola
Posts: 29
Joined: Mon Mar 11, 2013 4:38 pm

Python for SMILE

Post by Gardiola »

Good Morning,

I would lkike to know if someone has experience in Smile using Python ?

is there a wrapper in Python ? any other interfaces ?

Cheers.

Didier.
Martijn
Posts: 76
Joined: Sun May 29, 2011 12:23 am

Re: Python for SMILE

Post by Martijn »

Hi,

We do not have a Python wrapper available.
Not sure if anyone ever created one on their own.

Best,

Martijn
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Python for SMILE

Post by shooltz[BayesFusion] »

Martijn wrote:Not sure if anyone ever created one on their own.
We had a success report from the user who created Python wrapper with SWIG (www.swig.org) around 2006.
Gardiola
Posts: 29
Joined: Mon Mar 11, 2013 4:38 pm

Re: Python for SMILE

Post by Gardiola »

Thanks for your two posts.
kylnew
Posts: 2
Joined: Thu May 16, 2013 4:25 pm

Re: Python for SMILE

Post by kylnew »

Hey, I've actually been working on a project recently where I ultimately decided that the best thing for the job was SMILE but I was already well committed to python.

Let me say in advance DON'T do this with SWIG. I tried that first based on what I'd read on this board and it may have worked in the past but from what I can see it is really dated.

My advice is that you write some wrapper C functions that do the things you need and compile them and smile into a shared library. Then use Python's native ctypes functionality to load this library and call your functions.

Ultimately Bridging C++ and Python directly is difficult since Python is C based and if you want to do it without introducing new packages, ctypes and a wrapper is the way to go.

I've now succeeded on both Mac OSX and Linux, be aware that they compile differently. Here's a gist I have created for compiling on Linux and creating a .so shared library that Python's ctypes can read.
https://gist.github.com/bitwit/5621234

Hope this helps. It took a lot of hours to figure out, haha, I'm not a C/C++ guy at all really.
Gardiola
Posts: 29
Joined: Mon Mar 11, 2013 4:38 pm

Re: Python for SMILE

Post by Gardiola »

kylnew

I will have a look to your code.

I am working in windows....

In any case, thanks for your post !

Guardiola !
kylnew
Posts: 2
Joined: Thu May 16, 2013 4:25 pm

Re: Python for SMILE

Post by kylnew »

If you're on windows you'll need to make a DLL library I believe if that's the environment you are deploying the project in. Ours is a linux web server. It will be a matter of adjusting the Makefile appropriately, I believe.

Windows - .dll
Mac - .dylib
Linux - .so


At the conclusion of our project I might be able to share a bit more code that shows more elaborate and detailed examples (such as creating and passing structures in Python to be populated) but that won't be until some point in July
Gardiola
Posts: 29
Joined: Mon Mar 11, 2013 4:38 pm

Re: Python for SMILE

Post by Gardiola »

Kylnew,

thanks for your help and email.

It s appreciated.

As the natural language for smile is C++, I decided to do the implementation of my little problem in C++.

(I just refreshed my C++ skills in this purpose).

Thanks for this.

Gardiola

ps: I am still interested in your python code for the future.
Post Reply