I'm very comfortable with Swift, Obj-C, and Javascript but for a new project I need to use a library that is only available in Python. How do I integrate python or python scripts into an OSX project?
There is the option of going PyObjc or pyapp to build the entire application but that seems extravagant given that I only need Python for a small portion of that program.
It seems the preferable route would be to push Python to the cloud. Is there a pre bundled solution for doing this or would it require me to set up my own environment?
-
This seems relevant.Robert Harvey– Robert Harvey2016年06月09日 23:22:34 +00:00Commented Jun 9, 2016 at 23:22
2 Answers 2
If the amount of data that needs to be passed is small, then for an OS X application, one can run some Python code via a system() shell command from Swift or Objective C code.
For iOS, unless you want to build a Python interpreter into your app, it may be best to push running the Python library and scripts to a server "in the cloud".
-
That's exactly what I was thinking. I'm just not sure the tool kit to do that. I often write cloud code in js, just not Python. Any stack suggestions?Max Phillips– Max Phillips2016年06月12日 15:39:01 +00:00Commented Jun 12, 2016 at 15:39
For ways to embed Python code, see:
- Embedding Python in Another Application and a longer article on it and a tech talk video on it
- Embedding Python using Boost and a longer article about that
- Cython is an easy way to bridge Python with C family languages