Skip to content

Commit a9eee16

Browse files
authored
Merge pull request kivy#2527 from syrykh/fix/add-ifaddr-recipe
Add ifaddr recipe
2 parents 422c883 + a92323a commit a9eee16

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
4+
class IfaddrRecipe(PythonRecipe):
5+
name = 'ifaddr'
6+
version = '0.1.7'
7+
url = 'https://pypi.python.org/packages/source/i/ifaddr/ifaddr-{version}.tar.gz'
8+
depends = ['setuptools', 'ifaddrs', 'ipaddress;python_version<"3.3"']
9+
call_hostpython_via_targetpython = False
10+
patches = ["getifaddrs.patch"]
11+
12+
13+
recipe = IfaddrRecipe()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/ifaddr/_posix.py b/ifaddr/_posix.py
2+
index 2903ee7..546e3ce 100644
3+
--- a/ifaddr/_posix.py
4+
+++ b/ifaddr/_posix.py
5+
@@ -39,6 +39,10 @@ ifaddrs._fields_ = [('ifa_next', ctypes.POINTER(ifaddrs)),
6+
7+
libc = ctypes.CDLL(ctypes.util.find_library("socket" if os.uname()[0] == "SunOS" else "c"), use_errno=True)
8+
9+
+# On old Androids getifaddrs is not available in libc => use libifaddrs instead
10+
+if not hasattr(libc, 'getifaddrs'):
11+
+ libc = ctypes.CDLL(ctypes.util.find_library('ifaddrs'), use_errno=True)
12+
+
13+
def get_adapters():
14+
15+
addr0 = addr = ctypes.POINTER(ifaddrs)()

0 commit comments

Comments
 (0)