Continuing the discussion from Fortran package manager or python package manager?: I’m also aware of this discussion: https://github.com/fortran-lang/fpm/discussions/655 (and that there’s a command line work-around). Is this the full story to date? Or have I missed the labors of some kind soul who has put this into play? Many thanks.
Is your question how to create a shared library in fpm? I think we need to support it.
(I updated the title of this thread to reflect it. Feel free to change it.)
Yes, that’s the question – thanks for your reply and confirmation that it is not yet implemented.
I think you’re right – it would be great if it were supported. My interest is in using python ctypes for python-fortran interoperability. If I understand correctly (and I may not have this story right), the ctypes.CDLL class is the only way to interact with fortran dynamic (.so file) libraries within the ctypes package. (Please correct me if this is wrong.) Thanks again.
import numpy as np
mylib = np.ctypeslib.load_library(<shared_lib_name>,<abs_folder_path>)
Numpy has a wrapper around ctypes.cdll that is a bit more robust C-Types foreign function interface (numpy.ctypeslib) — NumPy v1.26 Manual.
But there are cross-platform considerations, such as library file extensions, plus the fact Windows will just load the first library it finds with that name. NumPy supplies the load_library function as a convenience.