import blosc2 hangs on macOS -- causes problems with tiled.client.register
When trying to import tiled.client.register I encountered a hang up that happens when trying to import the blosc2 file format library. The import will never return. When terminated I get the following response. A subprocess call to cpu_info never returns. macOS 15.1.1 on arm64
(tiled-client) esbarnard@esbstudio ~ % python
Python 3.11.11 (main, Dec 11 2024, 10:28:39) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tiled
>>> tiled.__version__
'0.1.0b11'
>>> from tiled.client.register import register
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/tiled/client/register.py", line 12, in <module>
from ..mimetypes import (
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/tiled/mimetypes.py", line 4, in <module>
from .serialization.table import XLSX_MIME_TYPE
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/tiled/serialization/table.py", line 4, in <module>
from ..media_type_registration import deserialization_registry, serialization_registry
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/tiled/media_type_registration.py", line 332, in <module>
import blosc2
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/blosc2/__init__.py", line 191, in <module>
cpu_info = get_cpu_info()
^^^^^^^^^^^^^^
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/blosc2/core.py", line 1192, in get_cpu_info
cpu_info_dict = _get_cpu_info()
^^^^^^^^^^^^^^^
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/blosc2/core.py", line 1156, in _get_cpu_info
cpu_info = cpuinfo.get_cpu_info()
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/cpuinfo/cpuinfo.py", line 2759, in get_cpu_info
output = get_cpu_info_json()
^^^^^^^^^^^^^^^^^^^
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/cpuinfo/cpuinfo.py", line 2742, in get_cpu_info_json
output = p1.communicate()[0]
^^^^^^^^^^^^^^^^
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/subprocess.py", line 1209, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/subprocess.py", line 2115, in _communicate
ready = selector.select(timeout)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/selectors.py", line 415, in select
fd_event_list = self._selector.poll(timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
Blosc2 version
(tiled-client) esbarnard@esbstudio ~ % conda list blosc2
# packages in environment at /Users/esbarnard/opt/anaconda3/envs/tiled-client:
#
# Name Version Build Channel
blosc2 3.0.0 pypi_0 pypi
Upon more investigation this is a bug in the py-cpuinfo that fails specifically on some macs / OS versions.
tested examples:
| Computer | macOS | python | works? |
|---|---|---|---|
| M3 Macbook Air | macOS 14.4 | Native Python 3.12 | WORKS |
| M3 Macbook Air | macOS 15.2 | Native Python 3.12 | WORKS |
| M1 Ultra Mac Studio | macOS 15.1.1 | Rosetta Python 3.12 | FAILS |
| M1 iMac | macOS 14.6.1 | Rosetta Python 3.12 | WORKS |
| Intel i9 MacBook Pro | macOS 15.0 | Native x86 Python 3.12 | WORKS |
Thanks for the thorough investigation. As a workaround, blosc2 is an optional dependency of Tiled. If it is not installed, blosc2 compression will not be used. Try uninstalling?
https://github.com/bluesky/tiled/blob/6314f1d42d4ca41643f6fee834b5129056fde130/tiled/client/decoders.py#L6-L29
pip uninstall blosc2 does the trick for now. I'll submit a issue to Blosc2 and py-cpuinfo
Blosc2 Issue posted: https://github.com/Blosc/python-blosc2/issues/356