From 60db23ba165dee3db848eaab4288e2c149681016 Mon Sep 17 00:00:00 2001 From: Ryan Pessa Date: Mon, 14 Dec 2015 13:03:46 -0600 Subject: [PATCH] add pyusb recipe --- pythonforandroid/recipes/pyusb/__init__.py | 13 ++++++ .../recipes/pyusb/fix-android.patch | 40 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 pythonforandroid/recipes/pyusb/__init__.py create mode 100644 pythonforandroid/recipes/pyusb/fix-android.patch diff --git a/pythonforandroid/recipes/pyusb/__init__.py b/pythonforandroid/recipes/pyusb/__init__.py new file mode 100644 index 0000000000..02eb0ecab5 --- /dev/null +++ b/pythonforandroid/recipes/pyusb/__init__.py @@ -0,0 +1,13 @@ +from pythonforandroid.recipe import PythonRecipe + + +class PyusbRecipe(PythonRecipe): + name = 'pyusb' + version = '1.0.0b1' + url = 'https://pypi.python.org/packages/source/p/pyusb/pyusb-{version}.tar.gz' + depends = [('python2', 'python3')] + + patches = ['fix-android.patch'] + + +recipe = PyusbRecipe() diff --git a/pythonforandroid/recipes/pyusb/fix-android.patch b/pythonforandroid/recipes/pyusb/fix-android.patch new file mode 100644 index 0000000000..a384584205 --- /dev/null +++ b/pythonforandroid/recipes/pyusb/fix-android.patch @@ -0,0 +1,40 @@ +--- pyusb-1.0.0b1.orig/usb/backend/libusb1.py 2013-10-21 12:56:10.000000000 -0500 ++++ pyusb-1.0.0b1/usb/backend/libusb1.py 2014-12-08 16:49:07.141514148 -0600 +@@ -265,13 +265,7 @@ + + def _load_library(): + if sys.platform != 'cygwin': +- candidates = ('usb-1.0', 'libusb-1.0', 'usb') +- for candidate in candidates: +- if sys.platform == 'win32': +- candidate = candidate + '.dll' +- +- libname = ctypes.util.find_library(candidate) +- if libname is not None: break ++ libname = '/system/lib/libusb1.0.so' + else: + # corner cases + # cygwin predefines library names with 'cyg' instead of 'lib' +@@ -672,16 +666,21 @@ + + # implementation of libusb 1.0 backend + class _LibUSB(usb.backend.IBackend): ++ ++ ran_init = False ++ + @methodtrace(_logger) + def __init__(self, lib): + usb.backend.IBackend.__init__(self) + self.lib = lib + self.ctx = c_void_p() + _check(self.lib.libusb_init(byref(self.ctx))) ++ self.ran_init = True + + @methodtrace(_logger) + def __del__(self): +- self.lib.libusb_exit(self.ctx) ++ if self.ran_init is True: ++ self.lib.libusb_exit(self.ctx) + + + @methodtrace(_logger)