void-packages/srcpkgs/python3-telegram/patches/use-system-tdlib.patch
Đoàn Trần Công Danh 49cb564d14 srcpkgs/p*: convert patches to -Np1
* par is kept at -Np0

```sh
git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.-][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.-][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

29 lines
1 KiB
Diff

# Patch from https://aur.archlinux.org/cgit/aur.git/plain/0001-Use-system-tdlib.diff?h=python-telegram
# Upstream issue: https://github.com/alexander-akhmetov/python-telegram/issues/119
diff --git a/telegram/tdjson.py b/telegram/tdjson.py
index 091145e..21c0361 100644
--- a/telegram/tdjson.py
+++ b/telegram/tdjson.py
@@ -2,6 +2,7 @@ import json
import logging
import platform
from ctypes import CDLL, CFUNCTYPE, c_int, c_char_p, c_double, c_void_p, c_longlong
+from ctypes.util import find_library
from typing import Any, Dict, Optional, Union
import pkg_resources
@@ -10,13 +11,7 @@ logger = logging.getLogger(__name__)
def _get_tdjson_lib_path() -> str:
- if platform.system().lower() == 'darwin':
- lib_name = 'darwin/libtdjson.dylib'
- else:
- lib_name = 'linux/libtdjson.so'
-
- return pkg_resources.resource_filename('telegram', f'lib/{lib_name}')
-
+ return find_library("tdjson")
class TDJson:
def __init__(self, library_path: Optional[str] = None, verbosity: int = 2) -> None: