prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  soundfile hook has osx/windows specific behaviour
  hook-soundfile.py was added in 3.5 but it blows up on linux as follows
  
      9727 INFO: Loading module hook "hook-soundfile.py"...
      Unable to find "/home/matt/.virtualenvs/beqdesigner-entpycF3/lib/python3.7/site-packages/_soundfile_data" when adding binary and data files.
  
  on OSX, it also fails but with a different error
  
      ValueError: Unknown Mach-O header: 0x20202020 in <_io.BufferedReader 
      name='/Users/travis/build/3ll3d00d/beqdesigner/.venv/lib/python3.7/site-packages/_soundfile_data/COPYING'>
  
  It completes successfully on Windows
  
  The problem is that pysoundfile packages libsndfile on Windows and OSX (as per https://pysoundfile.readthedocs.io/en/0.9.0/#installation) but relies on a system package on Linux so the mentioned directory (`_soundfile_data`) will not exist on Linux. On OSX only a certain file is required (`_soundfile_data/libsndfile.dylib`)
  
  Minimal test case can be found at https://github.com/3ll3d00d/pyinstaller-pysoundfile-bug
  
  
  --- 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-soundfile.py`
  Content:
  ```
  1 #-----------------------------------------------------------------------------
  2 # Copyright (c) 2016-2019, 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 """
  11 pysoundfile:
  12 https://github.com/bastibe/SoundFile
  13 """
  14 
  15 import os
  16 from PyInstaller.utils.hooks import get_package_paths
  17 
  18 # get path of soundfile
  19 sfp = get_package_paths('soundfile')
  20 
  21 # add the binaries
  22 bins = os.path.join(sfp[0], "_soundfile_data")
  23 binaries = [(bins, "_soundfile_data")]
  24
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/PyInstaller/hooks/hook-soundfile.py b/PyInstaller/hooks/hook-soundfile.py
  --- a/PyInstaller/hooks/hook-soundfile.py
  +++ b/PyInstaller/hooks/hook-soundfile.py
  @@ -13,11 +13,20 @@
   """
   
   import os
  +
  +from PyInstaller.compat import is_win, is_darwin
   from PyInstaller.utils.hooks import get_package_paths
   
   # get path of soundfile
   sfp = get_package_paths('soundfile')
   
  -# add the binaries
  -bins = os.path.join(sfp[0], "_soundfile_data")
  -binaries = [(bins, "_soundfile_data")]
  +# add binaries packaged by soundfile on OSX and Windows
  +# an external dependency (libsndfile) is used on GNU/Linux
  +path = None
  +if is_win:
  +    path = os.path.join(sfp[0], '_soundfile_data')
  +elif is_darwin:
  +    path = os.path.join(sfp[0], '_soundfile_data', 'libsndfile.dylib')
  +
  +if path is not None and os.path.exists(path):
  +    binaries = [(path, "_soundfile_data")]
  
verification_info: {"golden_diff": "diff --git a/PyInstaller/hooks/hook-soundfile.py b/PyInstaller/hooks/hook-soundfile.py\n--- a/PyInstaller/hooks/hook-soundfile.py\n+++ b/PyInstaller/hooks/hook-soundfile.py\n@@ -13,11 +13,20 @@\n \"\"\"\n \n import os\n+\n+from PyInstaller.compat import is_win, is_darwin\n from PyInstaller.utils.hooks import get_package_paths\n \n # get path of soundfile\n sfp = get_package_paths('soundfile')\n \n-# add the binaries\n-bins = os.path.join(sfp[0], \"_soundfile_data\")\n-binaries = [(bins, \"_soundfile_data\")]\n+# add binaries packaged by soundfile on OSX and Windows\n+# an external dependency (libsndfile) is used on GNU/Linux\n+path = None\n+if is_win:\n+    path = os.path.join(sfp[0], '_soundfile_data')\n+elif is_darwin:\n+    path = os.path.join(sfp[0], '_soundfile_data', 'libsndfile.dylib')\n+\n+if path is not None and os.path.exists(path):\n+    binaries = [(path, \"_soundfile_data\")]\n", "issue": "soundfile hook has osx/windows specific behaviour\nhook-soundfile.py was added in 3.5 but it blows up on linux as follows\r\n\r\n    9727 INFO: Loading module hook \"hook-soundfile.py\"...\r\n    Unable to find \"/home/matt/.virtualenvs/beqdesigner-entpycF3/lib/python3.7/site-packages/_soundfile_data\" when adding binary and data files.\r\n\r\non OSX, it also fails but with a different error\r\n\r\n    ValueError: Unknown Mach-O header: 0x20202020 in <_io.BufferedReader \r\n    name='/Users/travis/build/3ll3d00d/beqdesigner/.venv/lib/python3.7/site-packages/_soundfile_data/COPYING'>\r\n\r\nIt completes successfully on Windows\r\n\r\nThe problem is that pysoundfile packages libsndfile on Windows and OSX (as per https://pysoundfile.readthedocs.io/en/0.9.0/#installation) but relies on a system package on Linux so the mentioned directory (`_soundfile_data`) will not exist on Linux. On OSX only a certain file is required (`_soundfile_data/libsndfile.dylib`)\r\n\r\nMinimal test case can be found at https://github.com/3ll3d00d/pyinstaller-pysoundfile-bug\r\n\n", "before_files": [{"content": "#-----------------------------------------------------------------------------\n# Copyright (c) 2016-2019, 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\n\"\"\"\npysoundfile:\nhttps://github.com/bastibe/SoundFile\n\"\"\"\n\nimport os\nfrom PyInstaller.utils.hooks import get_package_paths\n\n# get path of soundfile\nsfp = get_package_paths('soundfile')\n\n# add the binaries\nbins = os.path.join(sfp[0], \"_soundfile_data\")\nbinaries = [(bins, \"_soundfile_data\")]\n", "path": "PyInstaller/hooks/hook-soundfile.py"}], "after_files": [{"content": "#-----------------------------------------------------------------------------\n# Copyright (c) 2016-2019, 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\n\"\"\"\npysoundfile:\nhttps://github.com/bastibe/SoundFile\n\"\"\"\n\nimport os\n\nfrom PyInstaller.compat import is_win, is_darwin\nfrom PyInstaller.utils.hooks import get_package_paths\n\n# get path of soundfile\nsfp = get_package_paths('soundfile')\n\n# add binaries packaged by soundfile on OSX and Windows\n# an external dependency (libsndfile) is used on GNU/Linux\npath = None\nif is_win:\n    path = os.path.join(sfp[0], '_soundfile_data')\nelif is_darwin:\n    path = os.path.join(sfp[0], '_soundfile_data', 'libsndfile.dylib')\n\nif path is not None and os.path.exists(path):\n    binaries = [(path, \"_soundfile_data\")]\n", "path": "PyInstaller/hooks/hook-soundfile.py"}]}