Support Apple Silicon (arm64)
PiN73 opened this issue · 3 comments
I'm getting error on macOS with M1 CPU
python-telegram version: 0.18.0
from telegram.client import Telegram
Telegram(
api_id='api_id',
api_hash='api_hash',
phone='+31611111111',
database_encryption_key='changekey123',
)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/.../env/lib/python3.9/site-packages/telegram/client.py", line 147, in __init__
self._tdjson = TDJson(library_path=library_path, verbosity=tdlib_verbosity)
File "/.../env/lib/python3.9/site-packages/telegram/tdjson.py", line 33, in __init__
self._build_client(library_path, verbosity)
File "/.../env/lib/python3.9/site-packages/telegram/tdjson.py", line 40, in _build_client
self._tdjson = CDLL(library_path)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 366, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/.../env/lib/python3.9/site-packages/telegram/lib/darwin/libtdjson.dylib, 0x0006): tried: '/.../env/lib/python3.9/site-packages/telegram/lib/darwin/libtdjson.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/.../env/lib/python3.9/site-packages/telegram/lib/darwin/libtdjson.dylib' (no such file), '/.../env/lib/python3.9/site-packages/telegram/lib/darwin/libtdjson.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
Issue is fixed by replacing telegram/lib/darwin/libtdjson.dylib
file to Universal 2 version
Universal 2 version can be taken from https://github.com/up9cloud/ios-libtdjson Releases -> libtdjson.xcframework.tar.gz
-> macos-arm64_x86_64/libtdjson.dylib
Thanks, it works! Though to prevent Mac from blocking an unknown lib one also needs to run xattr -r -d com.apple.quarantine telegram/lib/darwin/libtdjson.dylib
.
Issue is fixed by replacing
telegram/lib/darwin/libtdjson.dylib
file to Universal 2 versionUniversal 2 version can be taken from https://github.com/up9cloud/ios-libtdjson Releases ->
libtdjson.xcframework.tar.gz
->macos-arm64_x86_64/libtdjson.dylib
Hi,
I think that provide libtdjson.{dylib,so} is just a way to facilitate the user experience , but the best way would be get tdlib via the package manager.
In any case you don't need to replace file. If it does not work for you you can specify the lib in this way:
Telegram(
api_id='api_id',
api_hash='api_hash',
phone='+31611111111',
database_encryption_key='changekey123',
library_path='your_libtdjson_path_here'
)