8000 add pyusb recipe · simonsystem/python-for-android@60db23b · GitHub
[go: up one dir, main page]

Skip to content

Commit 60db23b

Browse files
committed
add pyusb recipe
1 parent eba92ab commit 60db23b

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-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 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()
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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)

0 commit comments

Comments
 (0)
0