whitews / FlowUtils

FlowUtils is a Python package containing various utility functions related to flow cytometry analysis, primarily focused on compensation and transformation tasks commonly used within the flow community.
https://flowutils.readthedocs.io
BSD 3-Clause "New" or "Revised" License
14 stars 8 forks source link

FlowUtils on mac aarch64 + python 3.11 #10

Closed arogozhnikov closed 1 year ago

arogozhnikov commented 1 year ago

Hi, I have mac M1 with aarch64.

Previously flowkit and flowutils worked for me on python 3.10, currently it complains on wrong binary in a strange way:

Error message:

ImportError: dlopen(/Users/axelr/pll/venv311/lib/python3.11/site-packages/flowutils/logicle_c.cpython-311-darwin.so, 0x0002): tried: '/Users/axelr/pll/venv311/lib/python3.11/site-packages/flowutils/logicle_c.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/axelr/pll/venv311/lib/python3.11/site-packages/flowutils/logicle_c.cpython-311-darwin.so' (no such file), '/Users/axelr/pll/venv311/lib/python3.11/site-packages/flowutils/logicle_c.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

Part of traceback:

File "/Users/axelr/pll/venv311/lib/python3.11/site-packages/flowkit/__init__.py", line 4, in <module>
    from ._models.sample import Sample
File "/Users/axelr/pll/venv311/lib/python3.11/site-packages/flowkit/_models/sample.py", line 19, in <module>
    from .._models.transforms import _transforms
File "/Users/axelr/pll/venv311/lib/python3.11/site-packages/flowkit/_models/transforms/__init__.py", line 2, in <module>
    from ._transforms import \
File "/Users/axelr/pll/venv311/lib/python3.11/site-packages/flowkit/_models/transforms/_transforms.py", line 4, in <module>
    import flowutils
File "/Users/axelr/pll/venv311/lib/python3.11/site-packages/flowutils/__init__.py", line 4, in <module>
    from . import compensate, transforms, gating
File "/Users/axelr/pll/venv311/lib/python3.11/site-packages/flowutils/transforms.py", line 8, in <module>
    from . import logicle_c

Setup: M1 Python 3.11.1 (installed from brew) Numpy 1.24.1 Flowutils were installed as:

# same error in all three cases
pip install flowutils
pip install flowutils --no-binary flowutils 
form source, using instruction here: https://github.com/whitews/FlowUtils#from-github-source-code
whitews commented 1 year ago

Hi Alex,

I haven't tested either library on Python 3.11, as there are several dependencies for FlowKit that do not yet support 3.11. That said, FlowUtils should be easier to get up and running. From your error message:

(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

Looks like you may have the x86 version of Python. Maybe brew is operating under Rosetta like in this SO post?

arogozhnikov commented 1 year ago

I'm quite confident I use arm version, but here is what file says:

$ file `which python`
/Users/axelr/pll/venv311/bin/python: Mach-O 64-bit executable arm64

I've also checked gcc, it is universal, so arm version should normally be used (same for g++):

file `which gcc`   
/usr/bin/gcc: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/gcc (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/gcc (for architecture arm64e): Mach-O 64-bit executable arm64e

LMK if you want me to check something else. From source it looks like it should build native version

whitews commented 1 year ago

Hmm, is pip caching a previous wheel version. Can you clear the pip cache or better yet try again with a fresh venv?

whitews commented 1 year ago

Setting up a Python 3.11.1 environment using pyenv, I was able to get FlowUtils to install on a M1 Mac using this command:

pip install --compile flowutils

My machine is using clang as the compiler and not gcc.

Does that work for you?

arogozhnikov commented 1 year ago

I've created a new env, and this time it worked.

The only thing changed: this time I updated pip before installing things, but that's unlikely the reason.

whitews commented 1 year ago

Great, actually that may be necessary, I have a note about upgrading pip for Mac in the FlowKit readme.