We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Can't package pyusb, 'Unable to find "libusb-1.0.so.0"'
To reproduce

1. `virtualenv env`
`source env/bin/activate`
`pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip`
`pip install pyusb`
`pip freeze > requirements.txt`
2. Create simple python file which imports pyusb
test.py
```
import usb.core
print 'Success!
```
3. Run the python file normally
```
$ python test.py
Success!
```
4. Package it with pyinstaller
```
pyinstaller --log-level=DEBUG test.py &> log.txt
```
log.txt
```
14 INFO: PyInstaller: 3.3.dev0+5fd013bfe
14 INFO: Python: 2.7.12+
14 INFO: Platform: Linux-4.8.0-53-generic-x86_64-with-Ubuntu-16.10-yakkety
14 INFO: wrote /home/joel/Code/random/pyinstaller/test.spec
15 DEBUG: Testing for UPX ...
17 INFO: UPX is not available.
17 DEBUG: script: /home/joel/Code/random/pyinstaller/test.py
17 INFO: Extending PYTHONPATH with paths
['/home/joel/Code/random/pyinstaller', '/home/joel/Code/random/pyinstaller']
17 INFO: checking Analysis
17 INFO: Building Analysis because out00-Analysis.toc is non existent
17 INFO: Initializing module dependency graph...
18 INFO: Initializing module graph hooks...
19 DEBUG: Hidden import: codecs
65 DEBUG: Hidden import 'codecs' already found
65 INFO: running Analysis out00-Analysis.toc
65 DEBUG: Analyzing /home/joel/Code/random/pyinstaller/env/bin/python
71 DEBUG: Skipping libdl.so.2 dependency of python
71 DEBUG: Skipping libc.so.6 dependency of python
71 DEBUG: Skipping libutil.so.1 dependency of python
71 DEBUG: Skipping libpthread.so.0 dependency of python
71 DEBUG: Skipping libm.so.6 dependency of python
72 DEBUG: Adding libz.so.1 dependency of python from /lib/x86_64-linux-gnu/libz.so.1
72 DEBUG: Analyzing /lib/x86_64-linux-gnu/libz.so.1
78 DEBUG: Skipping libc.so.6 dependency of libz.so.1
78 INFO: Caching module hooks...
81 INFO: Analyzing /home/joel/Code/random/pyinstaller/test.py
1078 INFO: Loading module hooks...
1079 INFO: Loading module hook "hook-usb.py"...
Unable to find "libusb-1.0.so.0" when adding binary and data files.
```
This causes the packaging process to halt with an empty `dist/` and `build/test/` folders.

I dug around and found out, that `hook-usb.py` reports the binaries to be `[('libusb-1.0.so.0', '')]` and I think this causes that  `src_root_path_or_glob`(`utils.py`, lines 450+) to just contain 'libusb1.0.so.0', which produces just `[]`after it get's run through the `glob.glob()` and not the real path, which I think is`/lib/x86_64-linux-gnu/libusb-1.0.so.0` on my computer.

Environment:
```
Python 2.7.12+
Ubuntu 16.10
Virtualenv 15.1.0
```
requirements.txt
```
appdirs==1.4.3
packaging==16.8
PyInstaller==3.3.dev0+5fd013bfe
pyparsing==2.2.0
pyusb==1.0.0
six==1.10.0
```

Also, this seems to be somewhat related to #1682 and commit https://github.com/pyinstaller/pyinstaller/commit/23901eb1ce7e60f1aac2a73e6cb3b02f1a34b9b1

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `PyInstaller/hooks/hook-usb.py`
Content:
```
1 #-----------------------------------------------------------------------------
2 # Copyright (c) 2013-2017, PyInstaller Development Team.
3 #
4 # Distributed under the terms of the GNU General Public License with exception
5 # for distributing bootloader.
6 #
7 # The full license is in the file COPYING.txt, distributed with this software.
8 #-----------------------------------------------------------------------------
9 
10 import ctypes.util
11 import os
12 import usb.core
13 import usb.backend
14 
15 from PyInstaller.depend.utils import _resolveCtypesImports
16 from PyInstaller.compat import is_cygwin
17 from PyInstaller.utils.hooks import logger
18 
19 
20 # Include glob for library lookup in run-time hook.
21 hiddenimports = ['glob']
22 
23 # https://github.com/walac/pyusb/blob/master/docs/faq.rst
24 # https://github.com/walac/pyusb/blob/master/docs/tutorial.rst
25 
26 binaries=[]
27 
28 # first try to use pyusb library locator
29 try:
30     # get the backend symbols before find
31     pyusb_backend_dir = set(dir(usb.backend))
32 
33     # perform find, which will load a usb library if found
34     usb.core.find()
35 
36     # get the backend symbols which have been added (loaded)
37     backends = set(dir(usb.backend)) - pyusb_backend_dir
38 
39     # for each of the loaded backends, see if they have a library
40     binaries = []
41     for usblib in [getattr(usb.backend, be)._lib for be in backends]:
42         if usblib is not None:
43             binaries = [(usblib._name, '')]
44 
45 except (ValueError, usb.core.USBError) as exc:
46     logger.warning("%s", exc)
47 
48 
49 # if nothing found, try to use our custom mechanism
50 if not binaries:
51     # Try to resolve your libusb libraries in the following order:
52     #
53     #   libusb-1.0, libusb-0.1, openusb
54     #
55     # NOTE: Mind updating run-time hook when adding further libs.
56     libusb_candidates = (
57         # libusb10
58         'usb-1.0', 'usb', 'libusb-1.0',
59         # libusb01
60         'usb-0.1', 'libusb0',
61         # openusb
62         'openusb',
63     )
64 
65     for candidate in libusb_candidates:
66         libname = ctypes.util.find_library(candidate)
67         if libname is not None:
68             break
69 
70     if libname is not None:
71         # Use basename here because Python returns full library path
72         # on Mac OSX when using ctypes.util.find_library.
73         bins = [os.path.basename(libname)]
74         binaries = _resolveCtypesImports(bins)
75     elif is_cygwin:
76         bins = ['cygusb-1.0-0.dll', 'cygusb0.dll']
77         binaries = _resolveCtypesImports(bins)[:1] # use only the first one
78     else:
79         binaries = []
80 
81     if binaries:
82         # `_resolveCtypesImports` returns a 3-tuple, but `binaries` are only
83         # 2-tuples, so remove the last element:
84         assert len(binaries[0]) == 3
85         binaries = [(binaries[0][1], '')]
86
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/PyInstaller/hooks/hook-usb.py b/PyInstaller/hooks/hook-usb.py
--- a/PyInstaller/hooks/hook-usb.py
+++ b/PyInstaller/hooks/hook-usb.py
@@ -40,7 +40,9 @@
     binaries = []
     for usblib in [getattr(usb.backend, be)._lib for be in backends]:
         if usblib is not None:
-            binaries = [(usblib._name, '')]
+            binaries = _resolveCtypesImports([os.path.basename(usblib._name)])
+            assert len(binaries[0]) == 3
+            binaries = [(binaries[0][1], '')]
 
 except (ValueError, usb.core.USBError) as exc:
     logger.warning("%s", exc)

{"golden_diff": "diff --git a/PyInstaller/hooks/hook-usb.py b/PyInstaller/hooks/hook-usb.py\n--- a/PyInstaller/hooks/hook-usb.py\n+++ b/PyInstaller/hooks/hook-usb.py\n@@ -40,7 +40,9 @@\n     binaries = []\n     for usblib in [getattr(usb.backend, be)._lib for be in backends]:\n         if usblib is not None:\n-            binaries = [(usblib._name, '')]\n+            binaries = _resolveCtypesImports([os.path.basename(usblib._name)])\n+            assert len(binaries[0]) == 3\n+            binaries = [(binaries[0][1], '')]\n \n except (ValueError, usb.core.USBError) as exc:\n     logger.warning(\"%s\", exc)\n", "issue": "Can't package pyusb, 'Unable to find \"libusb-1.0.so.0\"'\nTo reproduce\r\n\r\n1. `virtualenv env`\r\n`source env/bin/activate`\r\n`pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip`\r\n`pip install pyusb`\r\n`pip freeze > requirements.txt`\r\n2. Create simple python file which imports pyusb\r\ntest.py\r\n```\r\nimport usb.core\r\nprint 'Success!\r\n```\r\n3. Run the python file normally\r\n```\r\n$ python test.py\r\nSuccess!\r\n```\r\n4. Package it with pyinstaller\r\n```\r\npyinstaller --log-level=DEBUG test.py &> log.txt\r\n```\r\nlog.txt\r\n```\r\n14 INFO: PyInstaller: 3.3.dev0+5fd013bfe\r\n14 INFO: Python: 2.7.12+\r\n14 INFO: Platform: Linux-4.8.0-53-generic-x86_64-with-Ubuntu-16.10-yakkety\r\n14 INFO: wrote /home/joel/Code/random/pyinstaller/test.spec\r\n15 DEBUG: Testing for UPX ...\r\n17 INFO: UPX is not available.\r\n17 DEBUG: script: /home/joel/Code/random/pyinstaller/test.py\r\n17 INFO: Extending PYTHONPATH with paths\r\n['/home/joel/Code/random/pyinstaller', '/home/joel/Code/random/pyinstaller']\r\n17 INFO: checking Analysis\r\n17 INFO: Building Analysis because out00-Analysis.toc is non existent\r\n17 INFO: Initializing module dependency graph...\r\n18 INFO: Initializing module graph hooks...\r\n19 DEBUG: Hidden import: codecs\r\n65 DEBUG: Hidden import 'codecs' already found\r\n65 INFO: running Analysis out00-Analysis.toc\r\n65 DEBUG: Analyzing /home/joel/Code/random/pyinstaller/env/bin/python\r\n71 DEBUG: Skipping libdl.so.2 dependency of python\r\n71 DEBUG: Skipping libc.so.6 dependency of python\r\n71 DEBUG: Skipping libutil.so.1 dependency of python\r\n71 DEBUG: Skipping libpthread.so.0 dependency of python\r\n71 DEBUG: Skipping libm.so.6 dependency of python\r\n72 DEBUG: Adding libz.so.1 dependency of python from /lib/x86_64-linux-gnu/libz.so.1\r\n72 DEBUG: Analyzing /lib/x86_64-linux-gnu/libz.so.1\r\n78 DEBUG: Skipping libc.so.6 dependency of libz.so.1\r\n78 INFO: Caching module hooks...\r\n81 INFO: Analyzing /home/joel/Code/random/pyinstaller/test.py\r\n1078 INFO: Loading module hooks...\r\n1079 INFO: Loading module hook \"hook-usb.py\"...\r\nUnable to find \"libusb-1.0.so.0\" when adding binary and data files.\r\n```\r\nThis causes the packaging process to halt with an empty `dist/` and `build/test/` folders.\r\n\r\nI dug around and found out, that `hook-usb.py` reports the binaries to be `[('libusb-1.0.so.0', '')]` and I think this causes that  `src_root_path_or_glob`(`utils.py`, lines 450+) to just contain 'libusb1.0.so.0', which produces just `[]`after it get's run through the `glob.glob()` and not the real path, which I think is`/lib/x86_64-linux-gnu/libusb-1.0.so.0` on my computer.\r\n\r\nEnvironment:\r\n```\r\nPython 2.7.12+\r\nUbuntu 16.10\r\nVirtualenv 15.1.0\r\n```\r\nrequirements.txt\r\n```\r\nappdirs==1.4.3\r\npackaging==16.8\r\nPyInstaller==3.3.dev0+5fd013bfe\r\npyparsing==2.2.0\r\npyusb==1.0.0\r\nsix==1.10.0\r\n```\r\n\r\nAlso, this seems to be somewhat related to #1682 and commit https://github.com/pyinstaller/pyinstaller/commit/23901eb1ce7e60f1aac2a73e6cb3b02f1a34b9b1\n", "before_files": [{"content": "#-----------------------------------------------------------------------------\n# Copyright (c) 2013-2017, PyInstaller Development Team.\n#\n# Distributed under the terms of the GNU General Public License with exception\n# for distributing bootloader.\n#\n# The full license is in the file COPYING.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n\nimport ctypes.util\nimport os\nimport usb.core\nimport usb.backend\n\nfrom PyInstaller.depend.utils import _resolveCtypesImports\nfrom PyInstaller.compat import is_cygwin\nfrom PyInstaller.utils.hooks import logger\n\n\n# Include glob for library lookup in run-time hook.\nhiddenimports = ['glob']\n\n# https://github.com/walac/pyusb/blob/master/docs/faq.rst\n# https://github.com/walac/pyusb/blob/master/docs/tutorial.rst\n\nbinaries=[]\n\n# first try to use pyusb library locator\ntry:\n    # get the backend symbols before find\n    pyusb_backend_dir = set(dir(usb.backend))\n\n    # perform find, which will load a usb library if found\n    usb.core.find()\n\n    # get the backend symbols which have been added (loaded)\n    backends = set(dir(usb.backend)) - pyusb_backend_dir\n\n    # for each of the loaded backends, see if they have a library\n    binaries = []\n    for usblib in [getattr(usb.backend, be)._lib for be in backends]:\n        if usblib is not None:\n            binaries = [(usblib._name, '')]\n\nexcept (ValueError, usb.core.USBError) as exc:\n    logger.warning(\"%s\", exc)\n\n\n# if nothing found, try to use our custom mechanism\nif not binaries:\n    # Try to resolve your libusb libraries in the following order:\n    #\n    #   libusb-1.0, libusb-0.1, openusb\n    #\n    # NOTE: Mind updating run-time hook when adding further libs.\n    libusb_candidates = (\n        # libusb10\n        'usb-1.0', 'usb', 'libusb-1.0',\n        # libusb01\n        'usb-0.1', 'libusb0',\n        # openusb\n        'openusb',\n    )\n\n    for candidate in libusb_candidates:\n        libname = ctypes.util.find_library(candidate)\n        if libname is not None:\n            break\n\n    if libname is not None:\n        # Use basename here because Python returns full library path\n        # on Mac OSX when using ctypes.util.find_library.\n        bins = [os.path.basename(libname)]\n        binaries = _resolveCtypesImports(bins)\n    elif is_cygwin:\n        bins = ['cygusb-1.0-0.dll', 'cygusb0.dll']\n        binaries = _resolveCtypesImports(bins)[:1] # use only the first one\n    else:\n        binaries = []\n\n    if binaries:\n        # `_resolveCtypesImports` returns a 3-tuple, but `binaries` are only\n        # 2-tuples, so remove the last element:\n        assert len(binaries[0]) == 3\n        binaries = [(binaries[0][1], '')]\n", "path": "PyInstaller/hooks/hook-usb.py"}], "after_files": [{"content": "#-----------------------------------------------------------------------------\n# Copyright (c) 2013-2017, PyInstaller Development Team.\n#\n# Distributed under the terms of the GNU General Public License with exception\n# for distributing bootloader.\n#\n# The full license is in the file COPYING.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n\nimport ctypes.util\nimport os\nimport usb.core\nimport usb.backend\n\nfrom PyInstaller.depend.utils import _resolveCtypesImports\nfrom PyInstaller.compat import is_cygwin\nfrom PyInstaller.utils.hooks import logger\n\n\n# Include glob for library lookup in run-time hook.\nhiddenimports = ['glob']\n\n# https://github.com/walac/pyusb/blob/master/docs/faq.rst\n# https://github.com/walac/pyusb/blob/master/docs/tutorial.rst\n\nbinaries=[]\n\n# first try to use pyusb library locator\ntry:\n    # get the backend symbols before find\n    pyusb_backend_dir = set(dir(usb.backend))\n\n    # perform find, which will load a usb library if found\n    usb.core.find()\n\n    # get the backend symbols which have been added (loaded)\n    backends = set(dir(usb.backend)) - pyusb_backend_dir\n\n    # for each of the loaded backends, see if they have a library\n    binaries = []\n    for usblib in [getattr(usb.backend, be)._lib for be in backends]:\n        if usblib is not None:\n            binaries = _resolveCtypesImports([os.path.basename(usblib._name)])\n            assert len(binaries[0]) == 3\n            binaries = [(binaries[0][1], '')]\n\nexcept (ValueError, usb.core.USBError) as exc:\n    logger.warning(\"%s\", exc)\n\n\n# if nothing found, try to use our custom mechanism\nif not binaries:\n    # Try to resolve your libusb libraries in the following order:\n    #\n    #   libusb-1.0, libusb-0.1, openusb\n    #\n    # NOTE: Mind updating run-time hook when adding further libs.\n    libusb_candidates = (\n        # libusb10\n        'usb-1.0', 'usb', 'libusb-1.0',\n        # libusb01\n        'usb-0.1', 'libusb0',\n        # openusb\n        'openusb',\n    )\n\n    for candidate in libusb_candidates:\n        libname = ctypes.util.find_library(candidate)\n        if libname is not None:\n            break\n\n    if libname is not None:\n        # Use basename here because Python returns full library path\n        # on Mac OSX when using ctypes.util.find_library.\n        bins = [os.path.basename(libname)]\n        binaries = _resolveCtypesImports(bins)\n    elif is_cygwin:\n        bins = ['cygusb-1.0-0.dll', 'cygusb0.dll']\n        binaries = _resolveCtypesImports(bins)[:1] # use only the first one\n    else:\n        binaries = []\n\n    if binaries:\n        # `_resolveCtypesImports` returns a 3-tuple, but `binaries` are only\n        # 2-tuples, so remove the last element:\n        assert len(binaries[0]) == 3\n        binaries = [(binaries[0][1], '')]\n", "path": "PyInstaller/hooks/hook-usb.py"}]}