8

I have some AI code developed in python 2.7 that uses non-standard libraries.

I intend to compile it to work with my iPhone app.

I wouldn't like to re-program everything so, is that a way to compile my python code + all dependencies into a static file so I can call it from my iOS app as a function?

Ben S
  • 68,394
  • 30
  • 171
  • 212
marcelosalloum
  • 3,481
  • 4
  • 39
  • 63
  • Are the non-standard libs open source? – Ben S Sep 18 '13 at 18:21
  • @marcelosalloum I am trying to use https://github.com/yann2192/pyelliptic library, but proper documentation is not mentioned in kivy.Could you please tell me steps for the same? – SandeepAggarwal May 26 '15 at 16:41
  • @SandeepAggarwal, I've never managed to make it work. It was pretty immature at the time, I couldn't make it work and never tried again. Good luck! – marcelosalloum May 26 '15 at 20:01

2 Answers2

6

kivy can do it

http://kivy.org/docs/guide/packaging-ios.html

also maybe look at https://itunes.apple.com/us/app/python-for-ios/id485729872?ls=1&mt=8

although I doubt you can just compile your existing project into it... you will need to re-write at least part of it and you can only use pure python libraries (kivy)

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179
  • If I use a solution with [Python 2.7 for iOS](https://itunes.apple.com/us/app/python-for-ios/id485729872?ls=1&mt=8) I'd need the user to have it installed, right? Therefore I woudn't relie on this option. Have u ever used Kivy? Does it really do the work? – marcelosalloum Sep 18 '13 at 19:04
  • Ive used it with android and it runs like a native app ... I havent had experience in IOS with it but I assume its the same ... its kind of difficult to set up but once you get your environment setup it just works – Joran Beasley Sep 18 '13 at 19:08
  • I coudn't compile the distribution version and got the following error: http://stackoverflow.com/questions/18905622/failed-to-compile-kivy-ios-distribution-on-mac. When(if) I solve it I will post it her too – marcelosalloum Sep 19 '13 at 22:00
  • kivy-ios is now using clang compiler instead ov llvm-gcc and [all appears to work now](https://github.com/kivy/kivy-ios/issues/63), thanks to [Mathieu Virbel](https://github.com/tito) – marcelosalloum Oct 09 '13 at 18:35
  • Mattieu is a great guy – Joran Beasley Oct 09 '13 at 21:53
1

iPhone apps must be Objective-C, C, C++ or Objective-C++. They cannot interpret Python code.

However, if you have access to the library source, you may be able to translate and then compile the Python source to C code.

I would look into the PyPy Toolchain as a starting point.

Ben S
  • 68,394
  • 30
  • 171
  • 212
  • 1
    I'm quite certain he isn't looking to just run some Python code in a shell but rather include it in another app. – Ben S Sep 18 '13 at 18:30
  • we build android apps in python with kivy where I work and it works fine ... I suspect you are right about the ios script thing ... but kivy basically does what he wants (with some limitations) – Joran Beasley Sep 18 '13 at 18:38