def find_imagemagick_configuration():

    # Easiest way: the user is telling us what to use.
    env_cflags = os.environ.get('SANPERA_IMAGEMAGICK_CFLAGS')
    env_ldflags = os.environ.get('SANPERA_IMAGEMAGICK_LDFLAGS')
    if env_cflags is not None or env_ldflags is not None:
        return dict(
            extra_compile_args=shlex.split(env_cflags or ''),
            extra_link_args=shlex.split(env_ldflags or ''),
        )

    # Easy way: pkg-config, part of freedesktop
    # Note that ImageMagick ships with its own similar program `Magick-config`,
    # but it's just a tiny wrapper around `pkg-config`, so why it even exists
    # is a bit of a mystery.
    try:
        compile_args = check_output(['pkg-config', 'ImageMagick', '--cflags']).decode('utf-8')
        link_args = check_output(['pkg-config', 'ImageMagick', '--libs']).decode('utf-8')
    except OSError:
        pass
    except CalledProcessError:
        # This means that pkg-config exists, but ImageMagick isn't registered
        # with it.  Odd, but not worth giving up yet.
        pass
    else:
        return dict(
            extra_compile_args=shlex.split(compile_args),
            extra_link_args=shlex.split(link_args),
        )

    # TODO this could use more fallback, but IM builds itself with different
    # names (as of some recent version, anyway) depending on quantum depth et
    # al.  the `wand` project just brute-force searches for the one it wants.
    # perhaps we could do something similar.  also, we only need the header
    # files for the build, so it would be nice to get away with only hunting
    # down the library for normal use.

    raise RuntimeError(
        "Can't find ImageMagick installation!\n"
        "If you're pretty sure you have it installed, please either install\n"
        "pkg-config or tell me how to find libraries on your platform."
    )


################################################################################
# FFI setup
Process network delete event.
dataset/ETHPy150Open eevee/sanpera/sanpera/_api_build.py/find_imagemagick_configuration--crossover with--dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/apps/saf/server/dfa_server.py/DfaServer.network_delete_event