Skip to content

Commit

Permalink
Merge pull request #1 from bastibe/master
Browse files Browse the repository at this point in the history
Update to bastibe
  • Loading branch information
marcelvanherk authored Mar 16, 2020
2 parents 18bce9f + 38e68f7 commit 4044f63
Show file tree
Hide file tree
Showing 12 changed files with 500 additions and 409 deletions.
34 changes: 34 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
language: c

sudo: required
dist: trusty

compiler:
- gcc

env:
- LUA_ENV=lua5.1 PY_ENV=python2.7 m_SUFFIX=
- LUA_ENV=lua5.3 PY_ENV=python2.7 m_SUFFIX=
- LUA_ENV=lua5.1 PY_ENV=python3.6 m_SUFFIX=m
- LUA_ENV=lua5.3 PY_ENV=python3.6 m_SUFFIX=m


before_install:
- sudo add-apt-repository -y "deb http://ppa.launchpad.net/grilo-team/travis/ubuntu trusty main"
- sudo add-apt-repository -y "deb http://ppa.launchpad.net/fkrull/deadsnakes/ubuntu trusty main"
- sudo apt-get update -qq

install:
- sudo apt-get install -qq --force-yes ${LUA_ENV}
- sudo apt-get install -qq --force-yes ${PY_ENV}
- sudo apt-get install -qq --force-yes lib${LUA_ENV}-dev
- sudo apt-get install -qq --force-yes lib${PY_ENV}-dev
- ${LUA_ENV} -v
- ${PY_ENV} --version

script:
- cmake -B./build -H. -DPYTHON_INCLUDE_DIR=/usr/include/${PY_ENV}${m_SUFFIX} -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/lib${PY_ENV}${m_SUFFIX}.so
- cmake --build ./build
- cd ./build/bin
- ${PY_ENV} ../../tests/test_lua.py
- ${LUA_ENV} ../../tests/test_py.lua
17 changes: 8 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ set(CMAKE_BUILD_TYPE_INIT "Release")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})


project(Lunatic)

find_package(Lua 5.1 REQUIRED)
find_package(PythonLibs REQUIRED)
find_package(Lua 5.1 REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)

include_directories(${LUA_INCLUDE_DIR})
include_directories(${PYTHON_INCLUDE_DIR})

add_subdirectory(src)

Expand All @@ -19,14 +18,14 @@ set_target_properties(python PROPERTIES
PREFIX "")

add_library(lua MODULE $<TARGET_OBJECTS:src>)
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if (WIN32)
set_target_properties(lua PROPERTIES
PREFIX ""
SUFFIX ".pyd")
else ()
else (WIN32)
set_target_properties(lua PROPERTIES
PREFIX "")
endif ()
endif (WIN32)

target_link_libraries(lua ${LUA_LIBRARIES} ${PYTHON_LIBRARIES})
target_link_libraries(python ${LUA_LIBRARIES} ${PYTHON_LIBRARIES})
target_link_libraries(lua ${LUA_LIBRARIES} ${PYTHON_LIBRARIES})
target_link_libraries(python ${LUA_LIBRARIES} ${PYTHON_LIBRARIES})
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[![Build Status](https://travis-ci.org/bastibe/lunatic-python.svg?branch=master)](https://travis-ci.org/bastibe/lunatic-python)

Details
=======

This is a fork of Lunatic Python, which can be found on the 'net at http://labix.org/lunatic-python.

Sadly, Lunatic Python is very much outdated and won't work with either a current Python or Lua.

This is an updated version of lunatic-python that works with Python 2.7 and Lua 5.1.
This is an updated version of lunatic-python that works with Python 2.7-3.x and Lua 5.1-5.3.
I tried contacting the original author of Lunatic Python, but got no response.

Installing
Expand Down
24 changes: 16 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@
if os.path.isfile("MANIFEST"):
os.unlink("MANIFEST")

presult, poutput = commands.getstatusoutput("pkg-config --exists lua5.2")
HAS_LUA5_2 = (presult == 0)

# You may have to change these
LUAVERSION = "5.2"
if HAS_LUA5_2:
LUAVERSION = "5.2"
else:
LUAVERSION = "5.1"

PYTHONVERSION = get_python_version()
PYLIBS = ["python" + get_python_version(), "pthread", "util"]
PYLIBDIR = [get_python_lib(standard_lib=True) + "/config"]
Expand All @@ -30,18 +37,19 @@ def pkgconfig(*packages):
# map pkg-config output to kwargs for distutils.core.Extension
flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}

combined_pcoutput = ''
for package in packages:
(pcstatus, pcoutput) = commands.getstatusoutput(
"pkg-config --libs --cflags %s" % package)
if pcstatus == 0:
break
else:
sys.exit("pkg-config failed for %s; "
"most recent output was:\n%s" %
(", ".join(packages), pcoutput))
combined_pcoutput += ' ' + pcoutput
else:
sys.exit("pkg-config failed for %s; "
"most recent output was:\n%s" %
(", ".join(packages), pcoutput))

kwargs = {}
for token in pcoutput.split():
for token in combined_pcoutput.split():
if token[:2] in flag_map:
kwargs.setdefault(flag_map.get(token[:2]), []).append(token[2:])
else: # throw others to extra_link_args
Expand All @@ -56,7 +64,7 @@ def pkgconfig(*packages):

return kwargs

lua_pkgconfig = pkgconfig('lua' + LUAVERSION, 'lua' + LUAVERSION,'python-' + PYTHONVERSION)
lua_pkgconfig = pkgconfig('lua' + LUAVERSION, 'python-' + PYTHONVERSION)
lua_pkgconfig['extra_compile_args'] = ['-I/usr/include/lua'+LUAVERSION]

setup(name="lunatic-python",
Expand Down
15 changes: 10 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions(-DLUA_BUILD_AS_DLL)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions(-DLUA_LIB)

add_library(src OBJECT luainpython.c pythoninlua.c)
set_target_properties(src PROPERTIES
POSITION_INDEPENDENT_CODE TRUE)

target_include_directories(src PRIVATE ${LUA_INCLUDE_DIR} ${PYTHON_INCLUDE_DIR})

target_compile_definitions(src PRIVATE LUA_LIB)
if (WIN32)
target_compile_definitions(src PRIVATE LUA_BUILD_AS_DLL)
endif (WIN32)

if (CMAKE_COMPILER_IS_GNUCC)
target_compile_options(src PUBLIC -Wall -pedantic -std=c99)
endif (CMAKE_COMPILER_IS_GNUCC)
Loading

0 comments on commit 4044f63

Please sign in to comment.