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: 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();