How to find a specific Python module?

I have a specific Python module that currently happens to be located at

/home/software/plplot/installcmake/lib/python3.7/site-packages/_plplotc.so

The specific prefix part of that fullpath can be specified using the environment variable

CMAKE_PREFIX_PATH=/home/software/plplot/installcmake

But with that environment variable set,

find_library(PLPLOT_PYTHON_MODULE_LOCATION _plplotc)

does not find that module, and I assume that is because of the other
part of that python location, python3.7/site-packages varies from
platform to platform (i.e., is not standardized enough for CMake to
deal automatically with all the potential variations in that location for a given install
prefix).

I need some discussion of this python module find issue.
My guess at the moment is the best way to deal with this find issue
is to update the CONFIG mode of the PLplot package to include this
Python module location. If so and given that almost the entirety of
that current configuration is generated automatically, is there a
recommended way to update that configuration by hand to include the
python module location for PLplot? And if there is a better way
to deal with this find issue, please let me know what that is.

Alan

1 Like

Why do you need the path to that specific module?

What VTK does here is provide the path to add to PYTHONPATH to use for its Python code in its config file. https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/vtk-config.cmake.in#L157 Hmm. It’s not exactly turn-key, but VTK_PREFIX_PATH can be used to reconstruct it the full path (its value is what it is to facilitate install(DESTINATION) usage with it).

Why do you need the path to that specific module?

It was a test of whether find_library would work. But I just need the
directory location of that module so I was planning to adjust
PLPLOT_PYTHON_MODULE_LOCATION afterword if that find worked, but
it did not.

What VTK does here is provide the path to add to PYTHONPATH to use for its Python code in its config file.
[…] https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/vtk-config.cmake.in#L157

That approach (configuring the PLplot equivalent of
VTK_PYTHON_SITE_PACKAGES_SUFFIX in the overall PLplot find_package
config file) should work well for my needs. So thanks for this idea
which in retrospect is obvious, but my current plplotConfig.cmake file
is quite simple and not configured so I was drawing a blank on this
possiblity until your key help.