Skip to content

Commit e40e12b

Browse files
committed
chore: add support for MacOS arm64 architecture
1 parent d7aa536 commit e40e12b

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed
20.5 MB
Binary file not shown.

telegram/tdjson.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def _get_tdjson_lib_path() -> str:
1717
return system_library
1818

1919
if platform.system().lower() == 'darwin':
20-
lib_name = 'darwin/libtdjson.dylib'
20+
platform_architecture = platform.machine()
21+
lib_name = f'darwin/{platform_architecture}/libtdjson.dylib'
2122
else:
2223
lib_name = 'linux/libtdjson.so'
2324

tests/test_tdjson.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,33 @@
44

55

66
class TestGetTdjsonTdlibPath:
7-
def test_for_darwin(self):
7+
def test_for_darwin_x86_64(self):
88
mocked_system = Mock(return_value='Darwin')
9+
mocked_machine_name = Mock(return_value='x86_64')
910
mocked_resource = Mock()
1011
mocked_find_library = Mock(return_value=None)
1112

1213
with patch('telegram.tdjson.platform.system', mocked_system):
13-
with patch('telegram.tdjson.pkg_resources.resource_filename', mocked_resource):
14-
with patch('telegram.tdjson.ctypes.util.find_library', mocked_find_library):
15-
_get_tdjson_lib_path()
14+
with patch('telegram.tdjson.platform.machine', mocked_machine_name):
15+
with patch('telegram.tdjson.pkg_resources.resource_filename', mocked_resource):
16+
with patch('telegram.tdjson.ctypes.util.find_library', mocked_find_library):
17+
_get_tdjson_lib_path()
18+
19+
mocked_resource.assert_called_once_with('telegram', 'lib/darwin/x86_64/libtdjson.dylib')
20+
21+
def test_for_darwin_arm64(self):
22+
mocked_system = Mock(return_value='Darwin')
23+
mocked_machine_name = Mock(return_value='arm64')
24+
mocked_resource = Mock()
25+
mocked_find_library = Mock(return_value=None)
26+
27+
with patch('telegram.tdjson.platform.system', mocked_system):
28+
with patch('telegram.tdjson.platform.machine', mocked_machine_name):
29+
with patch('telegram.tdjson.pkg_resources.resource_filename', mocked_resource):
30+
with patch('telegram.tdjson.ctypes.util.find_library', mocked_find_library):
31+
_get_tdjson_lib_path()
1632

17-
mocked_resource.assert_called_once_with('telegram', 'lib/darwin/libtdjson.dylib')
33+
mocked_resource.assert_called_once_with('telegram', 'lib/darwin/arm64/libtdjson.dylib')
1834

1935
def test_for_linux(self):
2036
mocked_system = Mock(return_value='Linux')

0 commit comments

Comments
 (0)