#!/usr/bin/env python
# coding=utf-8
# Filename: setup.py
"""
KM3Pipe setup script.

"""
from setuptools import setup, Extension
import sys

if sys.version_info[0] >= 3:
    import builtins
else:
    import __builtin__ as builtins
try:
    from Cython.Distutils import build_ext
    from Cython.Build import cythonize
    # from Cython.Compiler.Options import directive_defaults
    import numpy
except ImportError:
    raise SystemExit("\nCython and Numpy are required to compile KM3Pipe.\n"
                     "You can install it easily via pip:\n\n"
                     "    > pip install cython numpy")


# This hack is "stolen" from numpy and allows to detect the setup procedure
# to avoid loading modules which are not compiled yet. Ugly but robust.
builtins.__KM3PIPE_SETUP__ = True

# Needed for line_profiler - disable for production code
directives = {
    'linetrace': True,
    'profile': True,
    'binding': True,
}
CYTHON_TRACE = '1'

from km3pipe import version  # noqa


tools = Extension('km3pipe.tools', sources=['km3pipe/tools.pyx'],
                  extra_compile_args=['-O3', '-march=native', '-w'],
                  include_dirs=[numpy.get_include()],
                  define_macros=[('CYTHON_TRACE', CYTHON_TRACE)])

core = Extension('km3pipe.core', sources=['km3pipe/core.pyx'],
                 extra_compile_args=['-O3', '-march=native', '-w'],
                 include_dirs=[numpy.get_include()],
                 define_macros=[('CYTHON_TRACE', CYTHON_TRACE)])

dataclasses = Extension('km3pipe.dataclasses',
                        sources=['km3pipe/dataclasses.pyx'],
                        extra_compile_args=['-O3', '-march=native', '-w'],
                        include_dirs=[numpy.get_include()],
                        define_macros=[('CYTHON_TRACE', CYTHON_TRACE)])

setup(name='km3pipe',
      version=version,
      url='http://github.com/tamasgal/km3pipe/',
      description='An analysis framework for KM3NeT',
      author='Tamas Gal and Moritz Lotze',
      author_email='tgal@km3net.de',
      packages=['km3pipe', 'km3pipe.testing', 'km3pipe.io', 'km3pipe.utils',
                'km3modules', 'pipeinspector'],
      ext_modules=cythonize([tools, core, dataclasses],
                            compiler_directives=directives),
      cmdclass={'build_ext': build_ext},
      include_package_data=True,
      platforms='any',
      install_requires=[
          'cython',
          'docopt',
          'matplotlib>=2.0.0',
          'mock',
          'numpy>=1.12',
          'pandas',
          'pytz',
          'scipy',
          'six',
          'tables',
          'h5py',
          'tornado',
          'urwid',
          'websocket-client',
      ],
      extras_require={
          'docs': ['sphinx>=1.5.1', 'sphinx-gallery', 'numpydoc',
                   'scikit-learn', 'statsmodels>=0.8', 'seaborn',
                   'pillow', 'ipython', 'sphinxcontrib-napoleon',
                   'astropy', 'h5py', 'patsy'],
          'jppy': ['jppy'],
          'testing': ['pytest', 'mock'],
      },
      entry_points={
          'console_scripts': [
              'km3pipe=km3pipe.cmd:main',
              'km3srv=km3pipe.srv:main',
              'tohdf5=km3pipe.utils.tohdf5:main',
              'hdf2root=km3pipe.utils.hdf2root:main',
              'pipeinspector=pipeinspector.app:main',
              'h5tree=km3pipe.utils.h5tree:main',
              'rtree=km3pipe.utils.rtree:main',
              'h5info=km3pipe.utils.h5info:main',
              'h5concat=km3pipe.utils.h5concat:main',
              'ptconcat=km3pipe.utils.ptconcat:main',
              'meantots=km3pipe.utils.meantots:main',
              'pushover=km3pipe.utils.pushover:main',
              'ztplot=km3pipe.utils.ztplot:main',
              'k40calib=km3pipe.utils.k40calib:main',
          ],
      },
      classifiers=[
          'Development Status :: 3 - Alpha',
          'Intended Audience :: Developers',
          'Intended Audience :: Science/Research',
          'Programming Language :: Python',
      ],
      )

__author__ = 'Tamas Gal'

@@ -2402,152 +2402,52 @@
 es=%5B
-%0A          'cython',%0A          'docopt',%0A          'matplotlib%3E=2.0.0',%0A          'mock',%0A          'numpy%3E=1.12',%0A          'pandas',%0A         
+'cython', 'docopt', 'numpy%3E=1.12', 'pandas',
  'py
@@ -2465,17 +2465,8 @@
     
-'scipy',%0A
     
@@ -2475,155 +2475,187 @@
     
+    
 'six',
-%0A
  
+%5D,%0A
       
-   'tables',%0A          'h5py',%0A          'tornado',%0A          'urwid',%0A          'websocket-client',%0A      %5D,%0A      extras_require=%7B%0A
+extras_require=%7B%0A          'docs': %5B'astropy', 'ipython', 'numpydoc', 'patsy', 'pillow',%0A                   'scikit-learn', 'seaborn', 'sphinx-gallery',%0A      
     
@@ -2660,25 +2660,19 @@
         
-'docs': %5B
+   
 'sphinx%3E
@@ -2691,58 +2691,193 @@
 hinx
--gallery', 'numpydoc',%0A                   'scikit-
+contrib-napoleon', 'statsmodels', %5D,%0A          'base': %5B'cython', 'docopt', 'numpy%3E=1.12', 'pandas', 'pytz',%0A                   'six', %5D,%0A          'analysis': %5B'matplotlib%3E=2.0.0', 'sk
 lear
@@ -2899,27 +2899,16 @@
 s%3E=0.8',
- 'seaborn',
 %0A       
@@ -2923,82 +2923,95 @@
     
-'pillow', 'ipython', 'sphinxcontrib-napoleon',%0A                   'astropy
+    'scipy', 'seaborn', %5D,%0A          'daq': %5B'controlhost', %5D,%0A          'io': %5B'tables
 ', '
@@ -3017,23 +3017,16 @@
 'h5py', 
-'patsy'
 %5D,%0A     
@@ -3034,17 +3034,16 @@
     'jpp
-y
 ': %5B'jpp
@@ -3043,17 +3043,78 @@
 : %5B'jppy
-'
+%3E=1.3.1', %5D,%0A          'web': %5B'tornado', 'websocket-client', 
 %5D,%0A     
@@ -3146,16 +3146,50 @@
 , 'mock'
+, %5D,%0A          'utils': %5B'urwid', 
 %5D,%0A     

clean up setup.py