Skip to content
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

Cannot find libgfortran, etc., on macOS when installed via pip #107

Open
anowacki opened this issue Sep 8, 2022 · 1 comment
Open

Cannot find libgfortran, etc., on macOS when installed via pip #107

anowacki opened this issue Sep 8, 2022 · 1 comment

Comments

@anowacki
Copy link

anowacki commented Sep 8, 2022

Thanks for maintaining stripy and apologies for the following limited bug report. I don't know much about Python packaging or wheel distribution I'm afraid.

I have tried installing stripy via pip install (and via Poetry), but when I do this I'm unable to load the dynamic libraries for the Fortran runtime:

$ pip install stripy
Collecting stripy
  Downloading stripy-2.1.0-cp38-cp38-macosx_10_14_x86_64.whl (13.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.0/13.0 MB 56.4 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.16.0 in /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from stripy) (1.23.2)
Requirement already satisfied: scipy>=1.0.0 in /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from stripy) (1.9.1)
Installing collected packages: stripy
Successfully installed stripy-2.1.0
In [1]: import stripy
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import stripy

File /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/stripy/__init__.py:34, in <module>
     30     if _os.path.isdir(extra_dll_dir):
     31         _os.environ["PATH"] += _os.pathsep + extra_dll_dir
---> 34 from .spherical import sTriangulation
     35 from .cartesian import Triangulation
     36 from . import spherical_meshes

File /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/stripy/spherical.py:21, in <module>
      1 """
      2 Copyright 2017-2019 Louis Moresi, Ben Mather
      3 
   (...)
     16 along with Stripy.  If not, see <http://www.gnu.org/licenses/>.
     17 """
     19 #!/usr/bin/python
     20 # -*- coding: utf-8 -*-
---> 21 from . import _stripack
     22 from . import _ssrfpack
     23 import numpy as np

ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/stripy/_stripack.cpython-38-darwin.so, 2): Library not loaded: /usr/local/opt/gcc@10/lib/gcc/10/libgfortran.5.dylib
  Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/stripy/_stripack.cpython-38-darwin.so
  Reason: image not found

It appears that the location of libgfortran (plus the other linked GCC libraries libquadmath and libgcc_s) relies on them being installed by Homebrew on macOS, whereas I have them installed elsewhere.

I don't know much about what might be possible, but I guess there are a few ways of approaching this:

  1. Require and document that these libraries need to be installed in those locations. That wouldn't be my favourite thing as I use a different package manager than Homebrew and others may do too.
  2. Distribute these libraries or rely on another package which distributes them, and code the linker path into them.
  3. Use install_name_tool to fix the linker paths (with @rpath?)

I'm happy to help diagnose things if that helps.

@anowacki
Copy link
Author

anowacki commented Sep 8, 2022

Just to be clear, this is where _stripack.cpython-38-darwin.so is looking for the libraries:

$ otool -L [redacted]/site-packages/stripy/_stripack.cpython-38-darwin.so
[redacted]/site-packages/stripy/_stripack.cpython-38-darwin.so:
	/usr/local/opt/gcc@10/lib/gcc/10/libgfortran.5.dylib (compatibility version 6.0.0, current version 6.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
	/usr/local/lib/gcc/10/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/local/opt/gcc@10/lib/gcc/10/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)

(libSystem is fine.)

anowacki added a commit to mantle-convection-constrained/terratools that referenced this issue Sep 8, 2022
This commit does not contain fully working code and will
be squashed in a future commit.

Add start of NetCDF file reading.

Note: NetCDF file format subject to change.

Add dependency on stripy (not working; see
underworldcode/stripy#107)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant