from os import path
from setuptools import setup, find_packages

MAIN_MODULE = 'agent'

# Find the agent package that contains the main module
packages = find_packages('.')
agent_package = ''
for package in find_packages():
    # Because there could be other packages such as tests
    if path.isfile(package + '/' + MAIN_MODULE + '.py') is True:
        agent_package = package
if not agent_package:
    raise RuntimeError('None of the packages under {dir} contain the file '
                       '{main_module}'.format(main_module=MAIN_MODULE + '.py',
                                              dir=path.abspath('.')))

# Find the version number from the main module
agent_module = agent_package + '.' + MAIN_MODULE
_temp = __import__(agent_module, globals(), locals(), ['__version__'], 0)
__version__ = _temp.__version__

# Setup
setup(
    name=agent_package + 'agent',
    version=__version__,
    install_requires=['volttron'],
    packages=packages,
    entry_points={
        'setuptools.installation': [
            'eggsecutable = ' + agent_module + ':main',
        ]
    }
)
