from collections import defaultdict
from distutils.core import Extension


def get_extensions():
    import numpy as np

    exts = []

    # malloc
    mac_incl_path = "/usr/include/malloc"

    cfg = defaultdict(list)
    cfg["include_dirs"].append(np.get_include())
    cfg["include_dirs"].append(mac_incl_path)
    cfg["include_dirs"].append("gala/integrate/cyintegrators")
    cfg["include_dirs"].append("gala/potential")
    cfg["extra_compile_args"].append("-std=c++17")
    cfg["sources"].append("gala/potential/potential/src/cpotential.cpp")
    cfg["sources"].append("gala/potential/hamiltonian/src/chamiltonian.cpp")
    cfg["sources"].append("gala/integrate/cyintegrators/dopri/dop853.cpp")
    cfg["sources"].append("gala/dynamics/lyapunov/dop853_lyapunov.pyx")
    exts.append(Extension("gala.dynamics.lyapunov.dop853_lyapunov", **cfg))

    cfg = defaultdict(list)
    cfg["include_dirs"].append(np.get_include())
    cfg["include_dirs"].append(mac_incl_path)
    cfg["include_dirs"].append("gala/potential")
    cfg["sources"].append("gala/dynamics/mockstream/_coord.pyx")
    cfg["extra_compile_args"].append("-std=c++17")
    exts.append(Extension("gala.dynamics.mockstream._coord", **cfg))

    cfg = defaultdict(list)
    cfg["include_dirs"].append(np.get_include())
    cfg["include_dirs"].append(mac_incl_path)
    cfg["include_dirs"].append("gala/potential")
    cfg["sources"].append("gala/dynamics/mockstream/df.pyx")
    cfg["sources"].append("gala/potential/potential/src/cpotential.cpp")
    cfg["extra_compile_args"].append("-std=c++17")
    exts.append(Extension("gala.dynamics.mockstream.df", **cfg))

    cfg = defaultdict(list)
    cfg["include_dirs"].append(np.get_include())
    cfg["include_dirs"].append("gala/integrate/cyintegrators")
    cfg["include_dirs"].append(mac_incl_path)
    cfg["include_dirs"].append("gala/potential")
    cfg["include_dirs"].append("gala/dynamics/nbody")
    cfg["sources"].append("gala/potential/potential/src/cpotential.cpp")
    cfg["sources"].append("gala/potential/hamiltonian/src/chamiltonian.cpp")
    cfg["sources"].append("gala/dynamics/mockstream/mockstream.pyx")
    cfg["sources"].append("gala/integrate/cyintegrators/dopri/dop853.cpp")
    cfg["extra_compile_args"].append("-std=c++17")
    exts.append(Extension("gala.dynamics.mockstream._mockstream", **cfg))

    cfg = defaultdict(list)
    cfg["include_dirs"].append(np.get_include())
    cfg["include_dirs"].append("gala/integrate/cyintegrators")
    cfg["include_dirs"].append(mac_incl_path)
    cfg["include_dirs"].append("gala/potential")
    cfg["sources"].append("gala/potential/potential/src/cpotential.cpp")
    cfg["sources"].append("gala/potential/hamiltonian/src/chamiltonian.cpp")
    cfg["sources"].append("gala/integrate/cyintegrators/dopri/dop853.cpp")
    cfg["sources"].append("gala/dynamics/nbody/nbody.pyx")
    cfg["extra_compile_args"].append("-std=c++17")
    exts.append(Extension("gala.dynamics.nbody.nbody", **cfg))

    return exts
