File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
pythonforandroid/recipes/pyusb Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ from pythonforandroid .recipe import PythonRecipe
2
+
3
+
4
+ class PyusbRecipe (PythonRecipe ):
5
+ name = 'pyusb'
6
+ version = '1.0.0b1'
7
+ url = 'https://pypi.python.org/packages/source/p/pyusb/pyusb-{version}.tar.gz'
8
+ depends = [('python2' , 'python3' )]
9
+
10
+ patches = ['fix-android.patch' ]
11
+
12
+
13
+ recipe = PyusbRecipe ()
Original file line number Diff line number Diff line change
1
+ --- pyusb-1.0.0b1.orig/usb/backend/libusb1.py 2013-10-21 12:56:10.000000000 -0500
2
+ +++ pyusb-1.0.0b1/usb/backend/libusb1.py 2014-12-08 16:49:07.141514148 -0600
3
+ @@ -265,13 +265,7 @@
4
+
5
+ def _load_library():
6
+ if sys.platform != 'cygwin':
7
+ - candidates = ('usb-1.0', 'libusb-1.0', 'usb')
8
+ - for candidate in candidates:
9
+ - if sys.platform == 'win32':
10
+ - candidate = candidate + '.dll'
11
+ -
12
+ - libname = ctypes.util.find_library(candidate)
13
+ - if libname is not None: break
14
+ + libname = '/system/lib/libusb1.0.so'
15
+ else:
16
+ # corner cases
17
+ # cygwin predefines library names with 'cyg' instead of 'lib'
18
+ @@ -672,16 +666,21 @@
19
+
20
+ # implementation of libusb 1.0 backend
21
+ class _LibUSB(usb.backend.IBackend):
22
+ +
23
+ + ran_init = False
24
+ +
25
+ @methodtrace(_logger)
26
+ def __init__(self, lib):
27
+ usb.backend.IBackend.__init__(self)
28
+ self.lib = lib
29
+ self.ctx = c_void_p()
30
+ _check(self.lib.libusb_init(byref(self.ctx)))
31
+ + self.ran_init = True
32
+
33
+ @methodtrace(_logger)
34
+ def __del__(self):
35
+ - self.lib.libusb_exit(self.ctx)
36
+ + if self.ran_init is True:
37
+ + self.lib.libusb_exit(self.ctx)
38
+
39
+
40
+ @methodtrace(_logger)
You can’t perform that action at this time.
0 commit comments