Closed brmather closed 4 years ago
The package on pypi is outdated and I think it is reasonable to publish a new version only after the review. Therefore, please install from source. Are you running on Linux or OSX? The tests on travis-ci indicate it should work with recent versions of numpy both on Linux and OSX. Does it work for you if you delete the option libraries=['lapack']
in line 18 in setup.py
?
I had a similar issue in #2.
I'm running Linux. Deleting libraries=['lapack']
line meant that I could install the package from source, but now I run into this error:
Traceback:
telewavesim/tests/test_utils.py:2: in <module>
from telewavesim import utils as ut
telewavesim/utils.py:36: in <module>
from telewavesim.rmat_f import conf as cf_f
E ModuleNotFoundError: No module named 'telewavesim.rmat_f'
which looks like it's not compiling the fortran source correctly? The second issue I was having is not related to Telewavesim
but rather a conflict in obspy
with a later version of pyproj
(https://github.com/obspy/obspy/issues/2445 and https://github.com/obspy/obspy/issues/2449).
It would not have surprised me, if you ran into ImpoertError - undefined symbol: dgeev_
, but this error seems strange. Are you still in the source directory? Maybe it is trying to import from there. Can you try to run the tests from an empty folder?
In light of this, I would suggest bundling a Docker image with Telewavesim - what do you think?
In my opinion, this would be overkill. Hopefully, in the end, there will be package on pypi for which the installation is simply working out of the box.
I have compiled lapack from source with shared libraries using cmake. When I run
f2py -c *.f90 -L/usr/local/lib64 -llapack -m rmat_f
from the src
folder it seems to compile fine but it returns an ImportError
:
ImportError Traceback (most recent call last)
<ipython-input-1-553ea2ea12ab> in <module>
----> 1 import rmat_f
ImportError: liblapack.so.3: cannot open shared object file: No such file or directory
/usr/local/lib64/liblapack.so.3
is there, but somehow f2py fails to link to it.
$ ldd rmat_f.cpython-36m-x86_64-linux-gnu.so
linux-vdso.so.1 (0x00007ffeb1569000)
liblapack.so.3 => not found
libpython3.6m.so.1.0 => /usr/lib/libpython3.6m.so.1.0 (0x00007f3987c75000)
libgfortran.so.5 => /usr/lib/libgfortran.so.5 (0x00007f3987668000)
libm.so.6 => /usr/lib/haswell/libm.so.6 (0x00007f3987528000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f398750d000)
libquadmath.so.0 => /usr/lib/libquadmath.so.0 (0x00007f39874bd000)
libc.so.6 => /usr/lib/haswell/libc.so.6 (0x00007f39872d4000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f39872b3000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f39872ad000)
libutil.so.1 => /usr/lib/libutil.so.1 (0x00007f39872a8000)
/usr/lib64/ld-linux-x86-64.so.2 (0x00007f3988030000)
Any advice on how to proceed would be appreciated.
I also do not know, what's wrong, but I have some ideas how to proceed:
export NPY_DISTUTILS_APPEND_FLAGS=1
before calling f2py
, this will be default in future numpy versions and we also set it when installing the package on travis-ci. (Edit: This flag was introduced with numpy 1.16.)>=1.15
? Some installation errors went away on travis, after pinning numpy to >=1.15
.export NPY_DISTUTILS_APPEND_FLAGS=1
doesn't appear to change anything.f2py
.
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "rmat_f" sources
f2py options: []
f2py:> /tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/rmat_fmodule.c
creating /tmp/tmpiwu4ku4f/src.linux-x86_64-3.6
Reading fortran codes...
Reading file 'rmat.f90' (format:free)
Reading file 'rmat_sub.f90' (format:fix)
Post-processing...
Block: rmat_f
Block: conf
In: :rmat_f:rmat.f90:conf
get_parameters: got "unexpected EOF while parsing (<string>, line 1)" on '3.141592653589793d0'
Block: rmat
Block: rmatrix
In: :rmat_f:rmat.f90:rmat:rmatrix
get_parameters: got "unexpected EOF while parsing (<string>, line 1)" on '3.141592653589793d0'
Block: rtfluid
In: :rmat_f:rmat.f90:rmat:rtfluid
get_parameters: got "unexpected EOF while parsing (<string>, line 1)" on '3.141592653589793d0'
Block: plane
Block: plane_land
In: :rmat_f:rmat.f90:plane:plane_land
get_parameters: got "unexpected EOF while parsing (<string>, line 1)" on '3.141592653589793d0'
Block: plane_obs
In: :rmat_f:rmat.f90:plane:plane_obs
get_parameters: got "unexpected EOF while parsing (<string>, line 1)" on '3.141592653589793d0'
Block: layer
Block: addit
Block: xeveci
Block: isotroc
Block: anisotroc
Block: xinv3
Block: rxinv3
Block: xmult3
Block: sort_evec
Block: reorder_evec
Block: sort_r
Block: cnorm
Post-processing (stage 2)...
Block: rmat_f
Block: unknown_interface
Block: conf
Block: rmat
Block: rmatrix
Block: rtfluid
Block: plane
Block: plane_land
Block: plane_obs
Block: layer
Block: addit
Block: xeveci
Block: isotroc
Block: anisotroc
Block: xinv3
Block: rxinv3
Block: xmult3
Block: sort_evec
Block: reorder_evec
Block: sort_r
Block: cnorm
Building modules...
Building module "rmat_f"...
Constructing wrapper function "layer"...
layer(omega,xh,eval,tu,td,rd)
Constructing wrapper function "addit"...
addit(nlay,ilay,tus,rus,tds,rds,tu,ru,td,rd)
Constructing wrapper function "xeveci"...
xeveci(evec,eveci)
Constructing wrapper function "isotroc"...
isotroc(vp,vs,dens,p11,p22,q,n)
Constructing wrapper function "anisotroc"...
anisotroc(c,dens,p11,p22,q,n)
Constructing wrapper function "xinv3"...
xinv3(a,ainv)
Constructing wrapper function "rxinv3"...
rxinv3(a,ainv)
Constructing wrapper function "xmult3"...
xmult3(a,b,c)
Constructing wrapper function "sort_evec"...
sort_evec(q,evec,[n])
Constructing wrapper function "reorder_evec"...
reorder_evec(evalr,evali,evecr,eveci,indx,eval,evec,[n])
Constructing wrapper function "sort_r"...
sort_r(a,indx,[m,n])
Constructing wrapper function "cnorm"...
cnorm(n,[nm])
Constructing F90 module support for "conf"...
Variables: pi nlaymx a thickn rho dp c rhof isoflg dt slow baz evals evecs tui rui tdi rdi
Constructing F90 module support for "rmat"...
Constructing wrapper function "rmat.rmatrix"...
tus,rus,tds,rds = rmatrix(px,py,omega,nlay,iter)
Constructing wrapper function "rmat.rtfluid"...
rtmat = rtfluid(p1,p2,a0,b0,rhos)
Constructing F90 module support for "plane"...
Constructing wrapper function "plane.plane_land"...
yx,yy,yz = plane_land(nt,nlay,wvtype)
Constructing wrapper function "plane.plane_obs"...
yx,yy,yz = plane_obs(nt,nlay,wvtype)
Wrote C/API module "rmat_f" to file "/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/rmat_fmodule.c"
Fortran 90 wrappers are saved to "/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/rmat_f-f2pywrappers2.f90"
adding '/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/fortranobject.c' to sources.
adding '/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6' to include_dirs.
copying /home/ben/.local/lib/python3.6/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmpiwu4ku4f/src.linux-x86_64-3.6
copying /home/ben/.local/lib/python3.6/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmpiwu4ku4f/src.linux-x86_64-3.6
adding '/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/rmat_f-f2pywrappers2.f90' to sources.
build_src: building npy-pkg config files
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
get_default_fcompiler: matching types: '['gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor']'
customize Gnu95FCompiler
Found executable /usr/bin/gfortran
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'rmat_f' extension
compiling C sources
C compiler: x86_64-solus-linux-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -mtune=generic -march=x86-64 -g2 -O2 -pipe -fPIC -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -I/usr/include -mtune=generic -march=x86-64 -g2 -O2 -pipe -fPIC -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector-strong --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -fPIC
creating /tmp/tmpiwu4ku4f/tmp
creating /tmp/tmpiwu4ku4f/tmp/tmpiwu4ku4f
creating /tmp/tmpiwu4ku4f/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6
compile options: '-I/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6 -I/home/ben/.local/lib/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -c'
x86_64-solus-linux-gcc: /tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/fortranobject.c
x86_64-solus-linux-gcc: /tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/rmat_fmodule.c
In file included from /home/ben/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,
from /home/ben/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /home/ben/.local/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from /tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/fortranobject.h:13,
from /tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/fortranobject.c:2:
/home/ben/.local/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
17 | #warning "Using deprecated NumPy API, disable it with " \
| ^~~
In file included from /home/ben/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,
from /home/ben/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /home/ben/.local/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from /tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/fortranobject.h:13,
from /tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/rmat_fmodule.c:16:
/home/ben/.local/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
17 | #warning "Using deprecated NumPy API, disable it with " \
| ^~~
/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/rmat_fmodule.c:144:12: warning: ‘f2py_size’ defined but not used [-Wunused-function]
144 | static int f2py_size(PyArrayObject* var, ...)
| ^~~~~
compiling Fortran 90 module sources
Fortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
compile options: '-I/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6 -I/home/ben/.local/lib/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -c'
extra options: '-J/tmp/tmpiwu4ku4f/ -I/tmp/tmpiwu4ku4f/'
gfortran:f90: rmat.f90
compiling Fortran sources
Fortran f77 compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /usr/bin/gfortran -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran fix compiler: /usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -fPIC -O3 -funroll-loops
compile options: '-I/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6 -I/home/ben/.local/lib/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -c'
extra options: '-J/tmp/tmpiwu4ku4f/ -I/tmp/tmpiwu4ku4f/'
gfortran:f90: rmat_sub.f90
gfortran:f90: /tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/rmat_f-f2pywrappers2.f90
/usr/bin/gfortran -Wall -g -Wall -g -shared /tmp/tmpiwu4ku4f/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/rmat_fmodule.o /tmp/tmpiwu4ku4f/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/fortranobject.o /tmp/tmpiwu4ku4f/rmat.o /tmp/tmpiwu4ku4f/rmat_sub.o /tmp/tmpiwu4ku4f/tmp/tmpiwu4ku4f/src.linux-x86_64-3.6/rmat_f-f2pywrappers2.o -L/usr/local/lib64 -L/usr/lib64/gcc/x86_64-solus-linux/9/../../../../lib64 -L/usr/lib64/gcc/x86_64-solus-linux/9/../../../../lib64 -L/usr/lib64 -llapack -lpython3.6m -lgfortran -o ./rmat_f.cpython-36m-x86_64-linux-gnu.so
Removing build directory /tmp/tmpiwu4ku4f
The f2py output does not look suspicious.
I am not an expert in this linking stuff. Nevertheless, maybe answers to this stackoverflow question are helpful?
Does ldconfig -p | grep lapack
output your freshly compiled library?
Does cat /etc/ld.so.conf.d/*.conf | grep /usr/local/lib64
output your lib directory?
If not that might be the reason for the problems. I think you could solve this problem by adding a new file to the /etc/ld.so.conf.d
folder with sudo echo "/usr/local/lib64" > /etc/ld.so.conf.d/usrlocallib64.conf
running sudo ldconfig
afterwards. (Alternatively check and set your $LD_LIBRARY_PATH environment variable).
That worked! I had to manually add /usr/local/lib64/
to my library path for rmat_f
to link against. Also, the fix in https://github.com/paudetseis/Telewavesim/issues/2#issuecomment-538487241 was required otherwise the fortran sources do not detect lapack (even if it's in my library path). So long as other installation methods work with these changes to setup.py
, they should be commited to master
.
I pushed a similar fix to master. I would appreciate if you could test it with your setup.
Thanks @trichter . @brmather , did you have a chance to test the fix? Hopefully it's all good now and we can move on.
Hi @trichter and @paudetseis,
The workaround in #33 did not work for me. The function get_library_dirs
in setup.py
could not locate lapack on my system so I submitted PR #34. This re-implements numpy's get_info
function to link lapack on compiling the fortran source code, and ensures the shared libraries are loaded on importing telewavesim
. I found this forum thread quite helpful.
This will likely not be an issue for the majority of users on Anaconda, but it should harden the installation procedure for people like me on native installs.
Feel free to modify the pull request as you see fit. As it stands I'm happy to close this issue and move on.
https://github.com/openjournals/joss-reviews/issues/1818
I am running into the following error with
pip install .
in the source directory:which suggests that it cannot find my lapack installation. However, if I run
pip install telewavesim
then it installs fine. Is there something new in the repo that is preventing me from installing this properly?In addition I run into the following issue when running the test suite:
which looks to be a dependency issue with
obspy
1.1.1. Switching to conda may resolve these dependency issues, but I try to avoid Anaconda as it has the tendency to mess up my system python configuration. In light of this, I would suggest bundling a Docker image withTelewavesim
- what do you think?