tsssss / geopack

Python version of geopack and Tsyganenko models
MIT License
30 stars 12 forks source link

scipy and M1 arm64 #12

Open rweigel opened 2 years ago

rweigel commented 2 years ago

My install of geopack failed on a M1 mac because the scipy install failed.

I was able to get it to work using

pip install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy

This isn't really a bug report but rather a comment to help others that may run into this issue.

In my code that uses geopack, I've added

import platform
import magnetovis as mvs

platform_str = platform.platform()
if platform_str.endswith('arm64-arm-64bit'):
    try:
        from geopack import geopack
    except:
        msg = 'pip install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy'
        msg = '\n\nThis function uses a library that depends on scipy. On Mac M1, you need to install scipy using: \n\n   ' + msg + '\n'
        raise ImportError(msg)

One thing to consider is the only place scipy is used is in t96.py. There, only scipy.special is used for Bessel functions. The scipy dependency adds 40 MB to the required packages and so one may want to consider using https://libraries.io/pypi/special-functions, which is only 2 MB and has no external dependencies.