# Buggy code
def _get_lib_name(lib, during_build):
    """
    Helper function to get an architecture and Python version specific library
    filename.

    :type during_build: bool
    :param during_build: Specifies whether the library name is requested during
        building ObsPy or inside ObsPy code. Numpy distutils adds a suffix to
        the filename we specify to build (as specified by Python builtin
        `sysconfig.get_config_var("EXT_SUFFIX")`. So when loading the file we
        have to add this suffix.
    """
    # our custom defined part of the extension filename
    libname = "lib%s_%s_%s_py%s" % (
        lib,
        platform.system(),
        platform.architecture()[0],
        "".join([str(i) for i in platform.python_version_tuple()[:2]]),
    )
    libname = cleanse_pymodule_filename(libname)
    # numpy distutils adds extension suffix by itself during build (#771, #755)
    if not during_build:
        # append any extension suffix defined by Python for current platform,
        # but strip ".so"
        ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
        if ext_suffix:
            if ext_suffix.endswith(".so"):
                ext_suffix = ext_suffix[:-3]
            libname = libname + ext_suffix
    return libname


# Traceback (ImportError)
$ python3 -c "import obspy.mseed"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "./obspy/__init__.py", line 43, in <module>
read.__doc__ % make_format_plugin_table("waveform", "read", numspaces=4)
File "./obspy/core/util/base.py", line 394, in make_format_plugin_table
"obspy.plugin.%s.%s" % (group, name), method)
File "/home/vagrant/python3/lib/python3.3/site-packages/setuptools-3.4.3-py3.3.egg/pkg_resources.py", line 351, in load_entry_point
File "/home/vagrant/python3/lib/python3.3/site-packages/setuptools-3.4.3-py3.3.egg/pkg_resources.py", line 2363, in load_entry_point
File "/home/vagrant/python3/lib/python3.3/site-packages/setuptools-3.4.3-py3.3.egg/pkg_resources.py", line 2088, in load
File "./obspy/mseed/core.py", line 15, in <module>
from obspy.mseed.headers import clibmseed, ENCODINGS, HPTMODULUS, \
File "./obspy/mseed/headers.py", line 39, in <module>
raise ImportError(msg)
ImportError: Could not load shared library for obspy.mseed.

./obspy/mseed/../lib/libmseed.so: cannot open shared object file: No such file or directory

# Fixed code
def _get_lib_name(lib, add_extension_suffix):
    """
    Helper function to get an architecture and Python version specific library
    filename.

    :type add_extension_suffix: bool
    :param add_extension_suffix: Numpy distutils adds a suffix to
        the filename we specify to build internally (as specified by Python
        builtin `sysconfig.get_config_var("EXT_SUFFIX")`. So when loading the
        file we have to add this suffix, but not during building.
    """
    # our custom defined part of the extension filename
    libname = "lib%s_%s_%s_py%s" % (
        lib,
        platform.system(),
        platform.architecture()[0],
        "".join([str(i) for i in platform.python_version_tuple()[:2]]),
    )
    libname = cleanse_pymodule_filename(libname)
    # numpy distutils adds extension suffix by itself during build (#771, #755)
    if add_extension_suffix:
        # append any extension suffix defined by Python for current platform,
        # but strip ".so"
        ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
        if ext_suffix:
            if ext_suffix.endswith(".so"):
                ext_suffix = ext_suffix[:-3]
            libname = libname + ext_suffix
    return libname