Skip to content

Commit

Permalink
Changes for ubuntu python library loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Jul 2, 2019
1 parent 96a293c commit 2f973fc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pdal/util/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ namespace Utils
{

#if defined(__APPLE__) && defined(__MACH__)
const std::string dynamicLibExtension = ".dylib";
const char dynamicLibExtension[] = ".dylib";
const char dirSeparator = '/';
const char pathListSeparator = ':';
#elif defined _WIN32
const std::string dynamicLibExtension = ".dll";
const char dynamicLibExtension[] = ".dll";
const char dirSeparator = '\\';
const char pathListSeparator = ';';
#else
const std::string dynamicLibExtension = ".so";
const char dynamicLibExtension[] = ".so";
const char dirSeparator = '/';
const char pathListSeparator = ':';
#endif
Expand Down
3 changes: 3 additions & 0 deletions plugins/python/filters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ PDAL_ADD_PLUGIN(python_libname filter python
${CMAKE_DL_LIBS}
INCLUDES
${NLOHMANN_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../plang/include
SYSTEM_INCLUDES
${PYTHON_ALL_INCLUDE_DIRS}
)
target_compile_definitions(pdal_plugin_filter_python PRIVATE
PDAL_PYTHON_LIBRARY="${PYTHON_LIBRARY}")

if (WITH_TESTS)
PDAL_ADD_TEST(pdal_filters_python_test
Expand Down
4 changes: 4 additions & 0 deletions plugins/python/io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ PDAL_ADD_PLUGIN(numpy_reader reader numpy
LINK_WITH
${PYTHON_LIBRARY}
${CMAKE_DL_LIBS}
INCLUDES
${CMAKE_CURRENT_BINARY_DIR}/include
SYSTEM_INCLUDES
${PYTHON_ALL_INCLUDE_DIRS}
)
target_compile_definitions(pdal_plugin_reader_numpy PRIVATE
PDAL_PYTHON_LIBRARY="${PYTHON_LIBRARY}")

# Install headers so Python extension
# can use them later
Expand Down
6 changes: 5 additions & 1 deletion plugins/python/plang/Environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@

#include "Environment.hpp"
#include "Redirector.hpp"

#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#define PY_ARRAY_UNIQUE_SYMBOL PDAL_ARRAY_API
#include <numpy/arrayobject.h>
#include <pdal/util/FileUtils.hpp>
#include <pdal/util/Utils.hpp>

#include <sstream>
Expand All @@ -67,7 +69,9 @@ static void loadPython()

pdal::Utils::getenv("PDAL_PYTHON_LIBRARY", libname);
if (libname.empty())
libname = "libPython" + pdal::Utils::dynamicLibExtension;
libname = PDAL_PYTHON_LIBRARY;
libname = pdal::FileUtils::getFilename(libname);
std::cerr << "Python library = " << libname << "!\n";
::dlopen(libname.data(), RTLD_LAZY | RTLD_GLOBAL);
}
#endif
Expand Down

0 comments on commit 2f973fc

Please sign in to comment.