dmitrii-eremin / python-lua Goto Github PK
View Code? Open in Web Editor NEWSimple python to lua translator.
License: Apache License 2.0
Simple python to lua translator.
License: Apache License 2.0
Can not run setup.py
Air:python-lua admin$ python3.5 setup.py
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py:245: UserWarning: 'licence' distribution option is deprecated; use 'license'
warnings.warn(msg)
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied
Air:python-lua admin$
The package name in setup.py does not appear to be registered on PyPI https://pypi.org/project/pythonlua/
This is a very interesting project, Dmitrii!
Is there a way to make the translator ignore things missing in the code and generate a translation anyway?
I wanted to code in Python the use of functions from binary Lua modules (C Lib), and then after translating they would of course be executed and loaded by Lua. But I get errors saying that this or that "is not defined" and the import will also try to locate a local Python script, so the compilation fails
I ran the tests on Python 3.6 & 3.8 and seven of the tests seem to have failures: simple_math (minor), unaryop, listdict, variables (minor), comprehensions, continue, for
Is that expected?
Testing file: tests/simple_math.py output: ['8', '16', '25', '32.0', '121.0', '5', '5.5', '172.18867924528', '']
expected: ['8', '16', '25', '32', '121', '5', '5.5', '172.18867924528', '']
FAILED
Testing file: tests/import.py PASSED
Testing file: tests/del.py PASSED
Testing file: tests/unaryop.py output: ['']
expected: ['-45\t-45\t44', 'true\tfalse', '']
FAILED
Testing file: tests/with.py PASSED
Testing file: tests/listdict.py output: ['5', '6', 'John\tDoe', '']
expected: ['2', '2', 'John\tDoe', 'Sara\t4', '']
FAILED
Testing file: tests/attributes.py PASSED
Testing file: tests/global.py PASSED
Testing file: tests/varargs.py PASSED
Testing file: tests/iterdict.py PASSED
Testing file: tests/variables.py output: ['100', '45', '4500', '2250.0', '']
expected: ['100', '45', '4500', '2250', '']
FAILED
Testing file: tests/defaultargs.py PASSED
Testing file: tests/decorator.py PASSED
Testing file: tests/lambda.py PASSED
Testing file: tests/nestedclass.py PASSED
Testing file: tests/comprehensions.py output: ['0', '2', '0', '2', '4', '0', '6', '0', '4', '8', '1\t1.0', '2\t4.0', '3\t9.0', '4\t16.0', '0\t0.0', '']
expected: ['2', '2', '4', '6', '6', '4', '8', '12', '10', '1\t1', '2\t4', '3\t9', '4\t16', '5\t25', '']
FAILED
Testing file: tests/in.py PASSED
Testing file: tests/ifelse.py PASSED
Testing file: tests/luacode.py PASSED
Testing file: tests/while.py PASSED
Testing file: tests/continue.py output: ['0\t * \t0\t = \t0', '0\t * \t1\t = \t0', '0\t * \t2\t = \t0', '0\t * \t3\t = \t0', '0\t * \t4\t = \t0', '0\t * \t5\t = \t0', '0\t * \t6\t = \t0', '0\t * \t8\t = \t0', '0\t * \t9\t = \t0', '1\t * \t0\t = \t0', '1\t * \t1\t = \t1', '1\t * \t2\t = \t2', '1\t * \t3\t = \t3', '1\t * \t4\t = \t4', '1\t * \t5\t = \t5', '1\t * \t6\t = \t6', '1\t * \t8\t = \t8', '1\t * \t9\t = \t9', '2\t * \t0\t = \t0', '2\t * \t1\t = \t2', '2\t * \t2\t = \t4', '2\t * \t3\t = \t6', '2\t * \t4\t = \t8', '2\t * \t5\t = \t10', '2\t * \t6\t = \t12', '2\t * \t8\t = \t16', '2\t * \t9\t = \t18', '3\t * \t0\t = \t0', '3\t * \t1\t = \t3', '3\t * \t2\t = \t6', '3\t * \t3\t = \t9', '3\t * \t4\t = \t12', '3\t * \t5\t = \t15', '3\t * \t6\t = \t18', '3\t * \t8\t = \t24', '3\t * \t9\t = \t27', '4\t * \t0\t = \t0', '4\t * \t1\t = \t4', '4\t * \t2\t = \t8', '4\t * \t3\t = \t12', '4\t * \t4\t = \t16', '4\t * \t5\t = \t20', '4\t * \t6\t = \t24', '4\t * \t8\t = \t32', '4\t * \t9\t = \t36', '6\t * \t0\t = \t0', '6\t * \t1\t = \t6', '6\t * \t2\t = \t12', '6\t * \t3\t = \t18', '6\t * \t4\t = \t24', '6\t * \t5\t = \t30', '6\t * \t6\t = \t36', '6\t * \t8\t = \t48', '6\t * \t9\t = \t54', '7\t * \t0\t = \t0', '7\t * \t1\t = \t7', '7\t * \t2\t = \t14', '7\t * \t3\t = \t21', '7\t * \t4\t = \t28', '7\t * \t5\t = \t35', '7\t * \t6\t = \t42', '7\t * \t8\t = \t56', '7\t * \t9\t = \t63', '8\t * \t0\t = \t0', '8\t * \t1\t = \t8', '8\t * \t2\t = \t16', '8\t * \t3\t = \t24', '8\t * \t4\t = \t32', '8\t * \t5\t = \t40', '8\t * \t6\t = \t48', '8\t * \t8\t = \t64', '8\t * \t9\t = \t72', '9\t * \t0\t = \t0', '9\t * \t1\t = \t9', '9\t * \t2\t = \t18', '9\t * \t3\t = \t27', '9\t * \t4\t = \t36', '9\t * \t5\t = \t45', '9\t * \t6\t = \t54', '9\t * \t8\t = \t72', '9\t * \t9\t = \t81', '']
expected: ['1\t * \t1\t = \t1', '1\t * \t2\t = \t2', '1\t * \t3\t = \t3', '1\t * \t4\t = \t4', '1\t * \t5\t = \t5', '1\t * \t6\t = \t6', '1\t * \t8\t = \t8', '1\t * \t9\t = \t9', '1\t * \t10\t = \t10', '2\t * \t1\t = \t2', '2\t * \t2\t = \t4', '2\t * \t3\t = \t6', '2\t * \t4\t = \t8', '2\t * \t5\t = \t10', '2\t * \t6\t = \t12', '2\t * \t8\t = \t16', '2\t * \t9\t = \t18', '2\t * \t10\t = \t20', '3\t * \t1\t = \t3', '3\t * \t2\t = \t6', '3\t * \t3\t = \t9', '3\t * \t4\t = \t12', '3\t * \t5\t = \t15', '3\t * \t6\t = \t18', '3\t * \t8\t = \t24', '3\t * \t9\t = \t27', '3\t * \t10\t = \t30', '4\t * \t1\t = \t4', '4\t * \t2\t = \t8', '4\t * \t3\t = \t12', '4\t * \t4\t = \t16', '4\t * \t5\t = \t20', '4\t * \t6\t = \t24', '4\t * \t8\t = \t32', '4\t * \t9\t = \t36', '4\t * \t10\t = \t40', '6\t * \t1\t = \t6', '6\t * \t2\t = \t12', '6\t * \t3\t = \t18', '6\t * \t4\t = \t24', '6\t * \t5\t = \t30', '6\t * \t6\t = \t36', '6\t * \t8\t = \t48', '6\t * \t9\t = \t54', '6\t * \t10\t = \t60', '7\t * \t1\t = \t7', '7\t * \t2\t = \t14', '7\t * \t3\t = \t21', '7\t * \t4\t = \t28', '7\t * \t5\t = \t35', '7\t * \t6\t = \t42', '7\t * \t8\t = \t56', '7\t * \t9\t = \t63', '7\t * \t10\t = \t70', '8\t * \t1\t = \t8', '8\t * \t2\t = \t16', '8\t * \t3\t = \t24', '8\t * \t4\t = \t32', '8\t * \t5\t = \t40', '8\t * \t6\t = \t48', '8\t * \t8\t = \t64', '8\t * \t9\t = \t72', '8\t * \t10\t = \t80', '9\t * \t1\t = \t9', '9\t * \t2\t = \t18', '9\t * \t3\t = \t27', '9\t * \t4\t = \t36', '9\t * \t5\t = \t45', '9\t * \t6\t = \t54', '9\t * \t8\t = \t72', '9\t * \t9\t = \t81', '9\t * \t10\t = \t90', '10\t * \t1\t = \t10', '10\t * \t2\t = \t20', '10\t * \t3\t = \t30', '10\t * \t4\t = \t40', '10\t * \t5\t = \t50', '10\t * \t6\t = \t60', '10\t * \t8\t = \t80', '10\t * \t9\t = \t90', '10\t * \t10\t = \t100', '']
FAILED
Testing file: tests/class.py PASSED
Testing file: tests/iterlist.py PASSED
Testing file: tests/factorial.py PASSED
Testing file: tests/for.py output: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '3', '']
expected: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '3', '']
FAILED
Testing file: tests/localvars.py PASSED
Testing file: tests/comments.py PASSED
================================================================================
Passed: 20/27
I have installed it with success but my system does not recognize the command python-lua.
I am on Ubuntu.
This is a very useful project, eager to use it.
Thanks a lot !
According to this :
python-lua/pythonlua/luainit.lua
Line 388 in 5e61488
It only checks if it's a list, but you could use in
in python even for hashtables, then you would need in lua just to do
if dict[key] then
python code being
if key in dict
Hello, I am originally a Python enthusiast but after some point my clients can't keep up with Python's performance. So I was at an adventure for searching transpilers/translator or a even a language that have similar syntax (because that's what make python great, our team have a great consulting performance even sometimes we code in front of our clients, but not computing performance surely). And now we actually have already found a working transpiler called Rapydscript (python to JS), but still we want more. Lua is now one of the most stable language to be ran on WebAssembly. And then I search for python to Lua transpiler/translator and found your project which is awesome. But on our simple benchmarks Lua is not that faster compared to Python 3 even sometimes slower. And that's even the luajit, the native lua interpreter is 3x slower. Do you have any insights on this?
Please desc any module needed in the README doc.
Air:python-lua admin$ python3.5 __main__.py t.py
Traceback (most recent call last):
File "__main__.py", line 7, in <module>
from pythonlua.config import Config
File "/Users/admin/GitHub/python-lua/pythonlua/config.py", line 3, in <module>
import yaml
ImportError: No module named 'yaml'
Air:python-lua admin$
You can't convert python to lua by inserting the keyword "local" in front of each line of code.
Try to convert this one and you'll see:
https://github.com/Broham/suncalcPy/blob/master/suncalc.py
Good free advice from me: delete this project, take a decent programming course and then try again.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.