16

This sounds like a weird question, so I'll explain circumstances surrounding first.

Basically, I have a 3D game development kit, written in Python, that works excellently by itself. However, most of my users will be used to using Lua as a scripting language, so I started to look at Lua-Python bindings.

I settled with Stefan Behnel's amazing Lupa library. However, it basically requires end-users to know how to compile applications, which is unacceptable for my GDK. Also, I normally can only access a Linux system, and since my game development kit runs on Windows and Mac OSX, the Windows binaries always lag behind, and my OSX users must compile my GDK themselves.

Does anyone know another alternative? Thank you!

P.S: I've already tried Lunatic Python, and Lux is too outdated.

DangerOnTheRanger
  • 456
  • 1
  • 3
  • 10
  • Yes, my first question :). I've been "lurking" around StackOverflow for years now, though... – DangerOnTheRanger Jun 04 '11 at 02:20
  • Do you like writing compilers? – Dhaivat Pandya Jun 04 '11 at 02:24
  • Actually, writing my own pure-Python Lua interpreter _is_ my fallback. Although, if no alternatives to Lupa come up, I'll might just stick with Lupa. – DangerOnTheRanger Jun 04 '11 at 02:38
  • why does lupa require compiling by the end user???? – daurnimator Jun 04 '11 at 08:54
  • 1
    Simple. Lupa itself isn't actually written in Python, it's written in [Cython](http://cython.org) - a superset of Python that compiles to C code. That C code (of course) must then be compiled. – DangerOnTheRanger Jun 04 '11 at 17:17
  • That's a tough one. The only options I can think of require compilation (or a complete implementation of Lua in pure Python). Do your users really need to use Lua? – Jasmijn Jun 05 '11 at 07:57
  • @Robin I actually tried making a pure-Python implementation of Lua, it didn't get far, and it took over 2 seconds to parse a 3-term expression. :( As for why I chose Lua, I chose it as that was the programming language I could assume they (> %80 of my users, as they're mostly coming from another closed-source GDK that uses Lua) were familiar with; however, I _might_ switch my GDK's scripting language, if this problem is unsolvable/its cost outweighs its benefit. – DangerOnTheRanger Jun 06 '11 at 23:07
  • @DangerOnTheRanger On the unlikely offchance that this was never solved satisfactorily for you, you could try just writing a bridge yourself. – Miles Rout Apr 24 '14 at 04:38
  • 2
    @MilesRout It's been a good 3 years since I initially had this problem, so I remember few details about it. If I recall correctly, I stuck with Lupa but compiled it for every platform I wanted to support, then distributed the compiled .so/dlls with my otherwise pure Python code. – DangerOnTheRanger Apr 24 '14 at 20:09

1 Answers1

4

you should look into lunatic-python it is a 2 way bridge between python and lua.

an example off the site shows how natural and easy it is:

>>> import lua
>>> lg = lua.globals()
>>> lg.string
<Lua table at 0x81c6a10>
>>> lg.string.lower
<Lua function at 0x81c6b30>
>>> lg.string.lower("Hello world!")
'hello world!'
Hortinstein
  • 2,667
  • 1
  • 22
  • 22
  • 3
    Like I said in my question, I've already tried Lunatic Python. The main problem I have with it is that it's very monolithic: Multiple scripts implicitly share globals if they're merely run with `lua.run`. That's the reason why I chose Lupa; multiple Lua interpreter instances can exist. – DangerOnTheRanger Jun 04 '11 at 05:28
  • 1
    Lunatic Python is kind of unmaintained now, it can be quite hard to figure out how to install. See There's a fork at https://github.com/bastibe/lunatic-python/issues/65#issuecomment-951888478 (and I write kind of an install instruction there) – user202729 Nov 01 '21 at 14:42