PDAL / python

PDAL's Python Support
Other
115 stars 34 forks source link

Are shared libraries going to the right location? #139

Closed j9ac9k closed 7 months ago

j9ac9k commented 1 year ago

PDAL 2.4.3 and Python-PDAL 3.1.2, libpdal_plugin_filter_python.dll and libpdal_plugin_reader_numpy.dll are placed in the %CONDA_PREFIX%\bin directory. This directory is problematic as it is not specified in PDAL_DRIVER_PATH.

The conda-forge feedstock recipe has an activation script that sets the PDAL_DRIVER_PATH to the following directory:

PDAL_DRIVER_PATH=%CONDA_PREFIX%\Library\bin;%CONDA_PREFIX%\lib\site-packages\bin

We do not see errors here because %CONDA_PREFIX%\bin is still added to %PATH% as part of the conda activation process. However, that directory is not specified in any activation scripts in %CONDA_PREFIX%\etc\conda\activate.d\*.bat, but that directory appears to be added to %PATH% by virtue of having an environment activated. In a created environment, the following paths relative to %CONDA_PREFIX% are added to %PATH%

%CONDA_PREFIX%
%CONDA_PREFIX%\Library\mingw-w64\bin
%CONDA_PREFIX%\Library\usr\bin
%CONDA_PREFIX%\Library\bin
%CONDA_PREFIX%\Scripts
%CONDA_PREFIX%\bin

By virtue of these results, we could consider doing away with 'PDAL_DRIVER_PATH' bit altogether (at least on Windows, other platforms would need to be evaluated).

In other environments where PDAL is getting used (cough ESRI cough) conda environments are not activated as they are in the terminal, but some directories within %CONDA_PREFIX% are still added to the %PATH%.

Specifically,

%CONDA_PREFIX%
%CONDA_PREFIX%\Library\bin
%CONDA_PREFIX%\Scripts

Browsing on that directory, this seems to be where the bulk of the DLLs are placed (note the 893 items).

image

Given that PDAL_DRIVER_PATH seems to point to %CONDA_PREFIX%\Library\bin, I suggest placing PDAL's DLLs in that directory instead of %CONDA_PREFIX%\bin.

Links: python-pdal-feestock activation script pdal activation script

Versions:

PDAL 2.4.3 PDAL-python 3.1.2

hobu commented 1 year ago

Given that PDAL_DRIVER_PATH seems to point to %CONDA_PREFIX%\Library\bin, I suggest placing PDAL's DLLs in that directory instead of %CONDA_PREFIX%\bin.

The Python plugins are installed by pip/scikit-build. The bin (not Library\bin) is picked up and set by the CMake configuration in scikit-build. I'm not quite sure how to change this.

That said, it is possible to have PDAL_DRIVER_PATH point to multiple directories – separated by the OS-sensitive path separator. The unix version of the activate script tries to figure out where the shared libraries are installed and points at them. I think you should do something similar, or figure out how to call the powershell or batch activate scripts.

hobu commented 7 months ago

https://github.com/PDAL/PDAL/pull/4291 upcoming in PDAL 2.7.0 has the potential to change this behavior. I expect scikit-build will pick up the expected directory names/locations that were previously custom to just PDAL's CMake configuration and use them. It still needs testing, however.