Skip to content

Commit

Permalink
Fix global symbol export for python (#2598)
Browse files Browse the repository at this point in the history
* Changes for ubuntu python library loading.

* Remove test check.

* Clean-up.
  • Loading branch information
abellgithub committed Jul 3, 2019
1 parent 96a293c commit c53d332
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
2 changes: 2 additions & 0 deletions plugins/python/filters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ PDAL_ADD_PLUGIN(python_libname filter python
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
2 changes: 2 additions & 0 deletions plugins/python/io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ PDAL_ADD_PLUGIN(numpy_reader reader numpy
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
9 changes: 8 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 @@ -66,8 +68,13 @@ static void loadPython()
std::string libname;

pdal::Utils::getenv("PDAL_PYTHON_LIBRARY", libname);
#
# PDAL_PYTHON_LIBRARY below is the result of the cmake FindPython script's
# PYTHON_LIBRARY.
#
if (libname.empty())
libname = "libPython" + pdal::Utils::dynamicLibExtension;
libname = PDAL_PYTHON_LIBRARY;
libname = pdal::FileUtils::getFilename(libname);
::dlopen(libname.data(), RTLD_LAZY | RTLD_GLOBAL);
}
#endif
Expand Down

0 comments on commit c53d332

Please sign in to comment.