Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
adbc843
Fix: Symbol not found error while loading dynamic python extensions.
adnanyaqoobvirk Mar 3, 2016
4584aa7
Buffer overflow fix while loading python library.
adnanyaqoobvirk Mar 3, 2016
53ab376
Merge pull request #47 from marcelvanherk/master
greatwolf Dec 12, 2016
d6c4e53
Turn on warnings.
greatwolf Dec 12, 2016
3ef1441
Merge pull request #48 from greatwolf/master
greatwolf Dec 12, 2016
a09c6c9
Don't wrap PyFunc in a lua closure by default.
greatwolf Feb 10, 2017
9f4f8ca
Refactored operators to use a python lambda instead.
greatwolf Feb 10, 2017
0998985
Minor refactor.
greatwolf Feb 10, 2017
0f993f6
Slight cleanup.
greatwolf Feb 10, 2017
43c3c98
Compatibility changes to make it buildable under Lua 5.3 and 5.1.
greatwolf Feb 10, 2017
8c9d8c4
Reduce indent level. Fixed bracing style.
greatwolf Feb 11, 2017
49a5c1d
Fixed reference leak.
greatwolf Feb 11, 2017
d84ed8e
Fix for issue #50 - coroutine param passing bug.
greatwolf Feb 12, 2017
ccaa087
Merge pull request #51 from greatwolf/fix_issue_50
greatwolf Feb 12, 2017
93dbdb5
Removed unused reference increase.
greatwolf Feb 13, 2017
cb4787d
Refactored not-so-good practice in cmake.
greatwolf Feb 16, 2017
7451aa8
Prefer 'target_include_directories';
greatwolf Feb 17, 2017
cc22c31
Added Python min version; formatting.
greatwolf Feb 17, 2017
6762b5d
travis CI.
greatwolf Feb 17, 2017
55c6bd9
Merge pull request #52 from greatwolf/travis
greatwolf Feb 18, 2017
079cca1
Travis build status to readme.
greatwolf Feb 18, 2017
a9a7a14
Fixed string conversion.
greatwolf Feb 19, 2017
f208848
Just have 'Py_None' convert to 'nil'. Keeping as udata doesn't
greatwolf Feb 22, 2017
1195d77
Rely more on lua's API instead of manual allocation.
greatwolf Feb 22, 2017
746a71e
Switched to 'PyRun_String' since no flags used here.
greatwolf Feb 25, 2017
b50fcc7
Added some tests from dmcooke/Lunatic-Python repo.
greatwolf Feb 25, 2017
dd6c153
Run test scripts in travis.yml.
greatwolf Feb 25, 2017
dd67b42
Fixed up py test for 2.7 and 3.3.
greatwolf Feb 25, 2017
28b2219
Formatting.
greatwolf Feb 25, 2017
973bff7
Reduce indent level.
greatwolf Feb 25, 2017
f4110cf
More formatting and bracing.
greatwolf Feb 25, 2017
33a8bdf
Fixed bug where 'asfunc' sets wrong upvalue if given multiple args.
greatwolf Feb 25, 2017
9bd504c
Merge branch 'tests'
greatwolf Feb 25, 2017
dc61478
Comparison support of lua values in py.
greatwolf Feb 26, 2017
1d41f31
Consolidated tests.
greatwolf Feb 26, 2017
27b7520
Fixed api changes between lua 5.1 and 5.2+.
greatwolf Feb 26, 2017
057b2da
Minor test fixup.
greatwolf Feb 26, 2017
24347a8
Simplified statement.
greatwolf Feb 26, 2017
5fb9b49
Added string test.
greatwolf Mar 2, 2017
da93144
Renamed to something more appropriate.
greatwolf Mar 2, 2017
438ac26
Fixed whitespace alignment.
greatwolf Mar 2, 2017
e7bddb0
Added test for attribute assignment.
greatwolf Mar 2, 2017
4d03194
DRY'ed up py operators with macro.
greatwolf Mar 2, 2017
3487161
Merge pull request #37 from adnanyaqoobvirk/master
greatwolf Mar 7, 2017
d1ff70d
Refactored python library name into compile-time string literal.
greatwolf Mar 7, 2017
1084df6
Have Test try to load dynamic py extensions that needs py runtime sym…
greatwolf Mar 7, 2017
e4a19ef
Test multiple statements in one execution.
greatwolf Mar 13, 2017
3156c37
Changed to allow multiline source execution.
greatwolf Mar 13, 2017
09d56fd
should not generate error if attribute not found on python object
Jayatubi May 11, 2017
4e70849
Update pythoninlua.c
greatwolf May 14, 2017
ccc5241
Merge pull request #58 from Jayatubi/master
greatwolf May 14, 2017
987efa4
Removed superfluous comparison.
greatwolf May 15, 2017
5ed46cc
Updated working versions in readme.
greatwolf May 15, 2017
280d5b1
Unnecessary cast, 'const char *' is expected anyway.
greatwolf May 15, 2017
6f25eb6
Updated travis build status to upstream.
greatwolf May 15, 2017
f6caa00
Fixed potential leak in `lua_run` issue #61
greatwolf Sep 18, 2017
10db774
Fixed variable name typo
greatwolf Sep 18, 2017
b43f5da
Bug fix: Combine pcoutput in pkgconfig
hosford42 Oct 6, 2017
a4eae70
Merge pull request #62 from hosford42/master
greatwolf Oct 6, 2017
7bb5bb5
Use LUA 5.1 if 5.2 doesn't exists on the system
Feb 23, 2020
38e68f7
Merge pull request #69 from danni-m/master
greatwolf Feb 26, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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