mapequation/infomap

infomap on M1 chip

Yquetzal opened this issue ยท 3 comments

Thanks for the nice work on infomap, I'm one of the maintainers of cdlib library, and we have reports of install failure due to the import of infomap on Macs with m1 chips.

I confirm I cannot make it work: using pip, it seems to install without error, but then when I try to do an import infomap, I get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/remycazabet/opt/anaconda3/envs/cdlib_test/lib/python3.8/site-packages/infomap.py", line 35, in <module>
    import _infomap
ImportError: dlopen(/Users/remycazabet/opt/anaconda3/envs/cdlib_test/lib/python3.8/site-packages/_infomap.cpython-38-darwin.so, 0x0002): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
  Referenced from: /Users/remycazabet/opt/anaconda3/envs/cdlib_test/lib/python3.8/site-packages/_infomap.cpython-38-darwin.so
  Reason: tried: '/usr/local/opt/libomp/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)

Even if I do brew install libomp before.

Same error if I try to run the command line infomap from command line.

Note that if I download the source code of infomap, I can compile it manually, and the command line works.

Is there a way to either 1)Provide binaries for Mac M1, or 2)compile the python library from sources ? (I tried to pip install locally with the setup.py but got an error ModuleNotFoundError: No module named 'package_meta' and stopped there)

Hi and thanks for reaching out and providing valuable feedback!

I'm running an M1 mac and had initial problems myself setting up the build.
What we did was to check brew --prefix and append that to the include and link flags.

We provide the binary wheels using GitHub hosted runners, and they currently don't support m1 macs, unfortunately.

Regarding package_meta.py, this file is generated during the build step (make python). See BUILD.md.

I know this is a "works on my machine ๐Ÿคท"-type answer. But please try building it on your machine or provide more detail as I don't have any other means to test this.

So, for a reason I don't really understand, I now can install it on a clean env with pip on a non-conda environement.
But it does not work with pip on a conda environment. When installing it, I see the line Downloading infomap-2.2.0-cp38-cp38-macosx_10_14_x86_64.whl (758 kB), which is fishy because of the "x86_64". So in that case pip try to install a wheel which is not available for the right system, apparently.

โฏ pip install infomap
Collecting infomap
  Downloading infomap-2.2.0-cp38-cp38-macosx_10_14_x86_64.whl (758 kB)
     |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 758 kB 6.0 MB/s 
Installing collected packages: infomap
Successfully installed infomap-2.2.0

And when trying to use it:

ImportError: dlopen(/Users/remycazabet/opt/anaconda3/envs/testcdlib/lib/python3.8/site-packages/_infomap.cpython-38-darwin.so, 0x0002): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
  Referenced from: /Users/remycazabet/opt/anaconda3/envs/testcdlib/lib/python3.8/site-packages/_infomap.cpython-38-darwin.so
  Reason: tried: '/usr/local/opt/libomp/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)

Thanks for the update, I will try to replicate this on my machine and get back to you!