"""
Defines how CORE will be built for installation.
"""

import glob
import os

from setuptools import find_packages, setup

_CORE_DIR = "/etc/core"
_MAN_DIR = "share/man/man1"
_EXAMPLES_DIR = "share/core"


def recursive_files(data_path, files_path):
    all_files = []
    for path, _directories, filenames in os.walk(files_path):
        directory = os.path.join(data_path, path)
        files = []
        for filename in filenames:
            files.append(os.path.join(path, filename))
        all_files.append((directory, files))
    return all_files


data_files = [
    (_CORE_DIR, glob.glob("data/*")),
    (_MAN_DIR, glob.glob("../man/**.1")),
]
data_files.extend(recursive_files(_EXAMPLES_DIR, "examples"))

setup(
    name="core",
    version="@PACKAGE_VERSION@",
    packages=find_packages(),
    install_requires=[
        'dataclasses;python_version=="3.6"',
        "fabric",
        "grpcio",
        "invoke",
        "lxml",
        "mako",
        "netaddr",
        "pillow",
        "protobuf",
        "pyproj",
        "pyyaml",
    ],
    tests_require=[
        "pytest",
    ],
    data_files=data_files,
    scripts=glob.glob("scripts/*"),
    include_package_data=True,
    description="Python components of CORE",
    url="https://github.com/coreemu/core",
    author="Boeing Research & Technology",
    license="BSD",
    long_description="Python scripts and modules for building virtual emulated networks.",
)