Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Apple Silicon (arm64) #377

Open
PiN73 opened this issue May 10, 2023 · 3 comments
Open

Support Apple Silicon (arm64) #377

PiN73 opened this issue May 10, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@PiN73
Copy link

PiN73 commented May 10, 2023

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'))
@PiN73
Copy link
Author

PiN73 commented May 10, 2023

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

@VPetukhov
Copy link

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.

@asarubbo
Copy link

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

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'
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants