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.
Python for SMILE
Re: Python for SMILE
Hi,
We do not have a Python wrapper available.
Not sure if anyone ever created one on their own.
Best,
Martijn
We do not have a Python wrapper available.
Not sure if anyone ever created one on their own.
Best,
Martijn
-
- Site Admin
- Posts: 1417
- Joined: Mon Nov 26, 2007 5:51 pm
Re: Python for SMILE
We had a success report from the user who created Python wrapper with SWIG (www.swig.org) around 2006.Martijn wrote:Not sure if anyone ever created one on their own.
Re: Python for SMILE
Thanks for your two posts.
Re: Python for SMILE
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.
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.
Re: Python for SMILE
kylnew
I will have a look to your code.
I am working in windows....
In any case, thanks for your post !
Guardiola !
I will have a look to your code.
I am working in windows....
In any case, thanks for your post !
Guardiola !
Re: Python for SMILE
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
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
Re: Python for SMILE
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.
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.