lunatic-python
lunatic-python copied to clipboard
any detailed installation guide on Ubuntu 16.04?
There isn't any installation guide in the README file. I've tried to use pip install lunatic-python but it didn't work. Could anyone provide the necessary guidance and hopefully update the README file?
This fork seems to be the most well-maintained one, although the instruction guide isn't that clear (unfortunately).
For the build/install itself, unfortunately it's not very obvious, but it's mentioned in several past (closed) issues, such as #74 .
Commonly-made mistakes
-
lunatic-python
package on pypi is the old package, not this fork. -
lunatic-python-universal
is this other fork OddSource/lunatic-python: A two-way bridge between Python and Lua. It can be installed from pip (as far as I can see, that would only allow calling Lua from Python, not vice versa, just like Lupa) - Do not run
make
at top level. The Makefile does not work anymore. - Do not run
python setup.py
at top level. The setup.py file does not work anymore since thePYTHON_LIBRT
update.
Build
cmake -B build
cmake --build build
Specify Python version
-
-DPYTHON_INCLUDE_DIR=/usr/include/python3.8 -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.8.so
-- reference: https://github.com/bastibe/lunatic-python/issues/74#issuecomment-623667750.
Specify Lua version
-
-D LUA_LIBRARY=/usr/lib/liblua5.3.so -D LUA_INCLUDE_DIR=/usr/include/lua5.3/
Note that if these 2 points to different Lua versions they will still compile but may raise "undefined symbol" error.
Documentation: https://cmake.org/cmake/help/latest/module/FindLua.html (TODO where is LUA_LIBRARY
documented?)
Result
After this you should get files build/bin/lua.so
and build/bin/python.so
, which are the libraries.
Install
Import Python from Lua
In order to allow require "python"
in Lua, copy the python.so
library to somewhere that Lua can access, such as /usr/lib/lua/5.4
or /usr/lib/lua/5.3
(checks package.cpath
and _VERSION
in Lua environment, for LuaLaTeX there are special instructions, see https://tex.stackexchange.com/a/372134/250119).
Import Lua from Python
Linking it to Python packages library with an appropriate name would work with the command
sudo ln -s -T /usr/local/lib/python3.8/dist-packages/lua.cpython-38-x86_64-linux-gnu.so /usr/local/lib/lua/5.1/python.so
Change the version accordingly.
Reference: https://github.com/bastibe/lunatic-python/issues/74#issue-607828875.