From 0361ea374a93df3d679fdf5091d1b845d925b2fc Mon Sep 17 00:00:00 2001 From: mpeterv Date: Sun, 25 Oct 2015 13:25:28 +0300 Subject: [PATCH] For Lua 5.1 look for modules locally first Lua 5.1 and LuaJIT have "?.lua" as the first entry in package.path, while Lua 5.2 and 5.3 have it as the last one. Respect this rule when patching default paths in luaconf.h. --- hererocks.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hererocks.py b/hererocks.py index 4a60be3..51b4e17 100755 --- a/hererocks.py +++ b/hererocks.py @@ -203,19 +203,25 @@ def patch_build_option(lua_path, old, new): makefile.close() def get_luarocks_paths(target_dir, nominal_version): + local_paths_first = nominal_version == "5.1" + module_path = os.path.join(target_dir, "share", "lua", nominal_version) - package_path = ";".join([ + module_path_parts = [ os.path.join(module_path, "?.lua"), - os.path.join(module_path, "?", "init.lua"), - os.path.join(".", "?.lua") - ]) + os.path.join(module_path, "?", "init.lua") + ] + module_path_parts.insert(0 if local_paths_first else 2, os.path.join(".", "?.lua")) + package_path = ";".join(module_path_parts) + cmodule_path = os.path.join(target_dir, "lib", "lua", nominal_version) so_extension = ".dll" if os.name == "nt" else ".so" - package_cpath = ";".join([ + cmodule_path_parts = [ os.path.join(cmodule_path, "?" + so_extension), - os.path.join(cmodule_path, "loadall" + so_extension), - os.path.join(".", "?" + so_extension) - ]) + os.path.join(cmodule_path, "loadall" + so_extension) + ] + cmodule_path_parts.insert(0 if local_paths_first else 2, os.path.join(".", "?" + so_extension)) + package_cpath = ";".join(cmodule_path_parts) + return package_path, package_cpath def apply_compat(lua_path, nominal_version, is_luajit, compat):