-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: f2py module giving 'symbol not found in flat namespace' on MacOS/Python 3.12 #25266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This particular issue is because Since the log shows |
Thanks, I'll try it. Is there a clean way to write the call so that it also covers the Python <3.11/distutils case? I guess |
I would personally drop If this is a dependency which can be discovered by |
I can't seem to get it to work either way. In the case of -L/-l ( |
Could you try with cd blah
# export LDFLAGS and LIBS here
meson compile -C bbdir works? Does it work on Linux? (should be the same though) EDIT: I'll check the upstream source out too. |
Thankfully I've been able to reproduce the issue on Linux, which is what my PC uses, and the same thing is happening (so that's good, I guess). I ran with The problem now is that when I run |
Could you add steps to reproduce this? I'm reopening this since it seems to be an |
Here's the command my cmake/make is running:
Let me know if there's more I can provide; it might take a while to distill it down to a simplified test case but I can do that if needed. As far as what I'm running: # (python 3.12 and meson 1.2.2 installed through spack; numpy 1.26.2 installed through pip)
git clone https://github.com/AlexanderRichert-NOAA/NCEPLIBS-bufr -b ci_updates_nov2023
cd NCEPLIBS-bufr/
mkdir build && cd build/
cmake .. -DENABLE_PYTHON=ON -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=$PWD/install
make -j2
export PYTHONPATH=$(realpath python):$PYTHONPATH
python -c "import ncepbufr" Result: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/dev/shm/NCEPLIBS-bufr/build/python/ncepbufr/__init__.py", line 9, in <module>
__bufrlib_version__ = _bufrlib.bvers().rstrip()
^^^^^^^^^^^^^^
AttributeError: module '_bufrlib' has no attribute 'bvers' |
That'd be awesome if you could, I'll likely not be able to dig deep into this until the weekend otherwise. |
I'm attaching a zip file with a test setup (just run sourceme.sh:
bvers.f:
_bufrlib.pyf:
ncepbufr/__init__.py:
|
I can't seem to reproduce this locally anymore: β― tree .
.
βββ _bufrlib.pyf
βββ bvers.f
βββ libbvers.a
βββ ncepbufr
βββ sourceme.sh
2 directories, 4 files
# Compile
β― gcc -fPIC -c bvers.f -o libbvers.a
# Version check (main)
β― f2py -v
2.0.0.dev0+git20231209.35c4319
# Distutils
β― f2py --verbose -c _bufrlib.pyf -m _bufrlib -L$PWD -lbvers --build-dir builddir-distutils
β― python -c "import ncepbufr" |& tee distutils.output
successful load
# Cleanup
β― rm -rf *.output *.so builddir*
# Meson
β― f2py --verbose -c _bufrlib.pyf -m _bufrlib -L$PWD -lbvers --backend meson --build-dir builddir-meson
β― python -c "import ncepbufr" |& tee meson.output
successful load The bvers = declare_dependency(link_args : ['-lbvers'])
lib_dir_0 = declare_dependency(link_args : ['-L/home/rgoswami/Git/Github/Quansight/numscipy_playground/numpy_bugs/gh-25266'])
py.extension_module('_bufrlib',
[
'_bufrlibmodule.c',
'_bufrlib-f2pywrappers.f',
fortranobject_c
],
include_directories: [inc_np],
dependencies : [
py_dep,
quadmath_dep,
bvers,
lib_dir_0,
],
install : true) Which was added last week in #25297. Please reopen if it persists @AlexanderRichert-NOAA. |
Describe the issue:
On MacOS when using Python 3.12 (i.e., meson rather than distutils), f2py does not appear to be incorporating Fortran-based functions from the provided library. Here's my f2py call:
f2py --verbose -c _bufrlib.pyf -m _bufrlib -L${CMAKE_BINARY_DIR}/src -lbufr_4
. For whatever reason, unlike under Linux, the objects defined in ${CMAKE_BINARY_DIR}/src/libbufr_4.a are not defined in the output object, i.e., _bufrlib.cpython-312-darwin.so does not contain the functions defined in my .a library. I've had no issues with Python <3.11 when using the distutils backend.Reproduce the code example:
Error message:
The text was updated successfully, but these errors were encountered: