You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am fairly certain I'm asking perhaps the most basic questions, but, well, I'm stuck. Namely, I sort of maintain some...not-pretty "use f2py in CMake" code that's from back in the day when f2py+CMake was a bit of a black art.
However @rgommersbrought up this project and then, independently, another person did as well. So, okay then, this might be useful.
So what I'm trying to do is translate some f2py code I have in a project I manage:
and translate into f2py-cmake. Now the "fun" part is that the Fortran code depends on some C code. I think our crazy homebuilt layer must be handling this (or I figured it out some other way), but I wasn't sure of the right way to do that here.
So, this is my first attempt to do this in a new fresh repo with:
find_package(
Python
COMPONENTS Interpreter Development.Module NumPy
REQUIRED)
include(UseF2Py)
# make a libshavemantissa library from shavemanitssa.cadd_library(shavemantissa shavemantissa.c)
# Create the F2Py `numpyobject` library.
f2py_object_library(f2py_object OBJECT)
f2py_generate_module(ShaveMantissa_
ShaveMantissa_py.F90
OUTPUT_VARIABLE shave_mantissa_files
)
python_add_library(ShaveMantissa_ MODULE "${shave_mantissa_files}" WITH_SOABI)
target_link_libraries(ShaveMantissa_ PRIVATE f2py_object)
target_link_libraries(ShaveMantissa_ PRIVATE shavemantissa)
install(TARGETS ShaveMantissa_ DESTINATION lib/Python/MAPL_cfio_r4)
install(PROGRAMS shavemantissa.py DESTINATION lib/Python/MAPL_cfio_r4)
# we also need to install the libraryinstall(TARGETS shavemantissa DESTINATION lib)
And, with this, it actually does seem to work. At least, something is built. But I can't seem to actually import it. If I go to my install:
❯ python3 -c 'import ShaveMantissa_'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: dlopen(/Users/mathomp4/Temp/MAPLpy/install/lib/Python/MAPL_cfio_r4/ShaveMantissa_.cpython-312-darwin.so, 0x0002): symbol not found in flat namespace '_shave32_'
Do you see anything in my above CMake that might cause this? Maybe I need some F2PY_ARGS?
Again, sorry if these are dumb questions. f2py has always been my antagonist in CMake land. 😄
The text was updated successfully, but these errors were encountered:
I am fairly certain I'm asking perhaps the most basic questions, but, well, I'm stuck. Namely, I sort of maintain some...not-pretty "use f2py in CMake" code that's from back in the day when f2py+CMake was a bit of a black art.
However @rgommers brought up this project and then, independently, another person did as well. So, okay then, this might be useful.
So what I'm trying to do is translate some f2py code I have in a project I manage:
and translate into
f2py-cmake
. Now the "fun" part is that the Fortran code depends on some C code. I think our crazy homebuilt layer must be handling this (or I figured it out some other way), but I wasn't sure of the right way to do that here.So, this is my first attempt to do this in a new fresh repo with:
And, with this, it actually does seem to work. At least, something is built. But I can't seem to actually
import
it. If I go to myinstall
:Do you see anything in my above CMake that might cause this? Maybe I need some
F2PY_ARGS
?Again, sorry if these are dumb questions. f2py has always been my antagonist in CMake land. 😄
The text was updated successfully, but these errors were encountered: