From 658f1ff459b9ebf3c85f389decf9f8dca8e8be6a Mon Sep 17 00:00:00 2001 From: Greatwolf Date: Mon, 27 Apr 2020 23:20:49 -0700 Subject: [PATCH 1/2] Updated to use xenial. Updated ppa repo links. Added Python 3.8 to test matrix. --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a59d666..9b914f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: c sudo: required -dist: trusty +dist: xenial compiler: - gcc @@ -11,11 +11,12 @@ env: - 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 + - LUA_ENV=lua5.1 PY_ENV=python3.8 m_SUFFIX= + - LUA_ENV=lua5.3 PY_ENV=python3.8 m_SUFFIX= 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 add-apt-repository -y ppa:deadsnakes/ppa - sudo apt-get update -qq install: From 28b6b9d53000b6c3082516f7f825b7e14c06bcad Mon Sep 17 00:00:00 2001 From: Greatwolf Date: Tue, 28 Apr 2020 01:02:51 -0700 Subject: [PATCH 2/2] Have CMake pass in the name of the python runtime being built with rather than guessing it in the source. This should also fix issue #74. --- src/CMakeLists.txt | 5 +++++ src/pythoninlua.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b4664b5..38c58a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,11 @@ if (WIN32) target_compile_definitions(src PRIVATE LUA_BUILD_AS_DLL) endif (WIN32) +if (UNIX) + get_filename_component(PYTHON_LIBRT ${PYTHON_LIBRARIES} NAME) + target_compile_definitions(src PRIVATE PYTHON_LIBRT=${PYTHON_LIBRT}) +endif (UNIX) + if (CMAKE_COMPILER_IS_GNUCC) target_compile_options(src PUBLIC -Wall -pedantic -std=c99) endif (CMAKE_COMPILER_IS_GNUCC) diff --git a/src/pythoninlua.c b/src/pythoninlua.c index c7b25ae..97e3ed9 100644 --- a/src/pythoninlua.c +++ b/src/pythoninlua.c @@ -634,12 +634,12 @@ LUA_API int luaopen_python(lua_State *L) */ #if defined(__linux__) # define STR(s) #s -#if PY_MAJOR_VERSION < 3 -# define PYLIB_STR(major, minor) "libpython" STR(major) "." STR(minor) ".so" -#else -# define PYLIB_STR(major, minor) "libpython" STR(major) "." STR(minor) "m.so" +# define PYLIB_STR(s) STR(s) +#if !defined(PYTHON_LIBRT) +# error PYTHON_LIBRT must be defined when building under Linux! #endif - dlopen(PYLIB_STR(PY_MAJOR_VERSION, PY_MINOR_VERSION), RTLD_NOW | RTLD_GLOBAL); + void *ok = dlopen(PYLIB_STR(PYTHON_LIBRT), RTLD_NOW | RTLD_GLOBAL); + assert(ok); (void) ok; #endif Py_Initialize();