from setuptools import setup, Extension, find_packages

on_rtd = False
try:
    from Cython.Distutils import build_ext
    from Cython.Build import cythonize
    import numpy
except ImportError:
    on_rtd = True
    numpy = None
    build_ext = None
    
import os

def readme():
    with open('README.rst') as f:
        return f.read()

# Hackishly inject a constant into builtins to enable importing of the
# package before the library is built.
import sys
if sys.version_info[0] < 3:
    import __builtin__ as builtins
else:
    import builtins
builtins.__VESPA_SETUP__ = True
import vespa
version = vespa.__version__


# Publish the library to PyPI.
if "publish" in sys.argv[-1]:
    os.system("python setup.py sdist upload")
    sys.exit()

# Push a new tag to GitHub.
if "tag" in sys.argv:
    os.system("git tag -a {0} -m 'version {0}'".format(version))
    os.system("git push --tags")
    sys.exit()

if not on_rtd:
    transit_utils = [Extension('vespa._transitutils',['vespa/_transitutils.pyx'],
                                include_dirs=[numpy.get_include()])]
else:
    transit_utils = None
        
setup(name = "VESPA",
      version = version,
      description = "Calculate astrophysical false positive probabilities for transiting exoplanet signals",
      long_description = readme(),
      author = "Timothy D. Morton",
      author_email = "tim.morton@gmail.com",
      url = "https://github.com/timothydmorton/VESPA",
      #packages = ['vespa', 'vespa/stars',
      #            'vespa/orbits'],
      packages = find_packages(),
      package_data = {'vespa': ['data/*', 'tests/*.ini',
                                'tests/*.h5', 'tests/*.pkl',
                                'tests/*.cc'],
                      'vespa.stars': ['data/*'],
                      'vespa.orbits':['data/*']},
      ext_modules = cythonize(transit_utils),
      scripts = ['scripts/get_trilegal',
                 'scripts/koifpp',
                 'scripts/batch_koifpp_condor',
                 'scripts/calcfpp',
                 'scripts/koifpp-config',
                 'scripts/get_kepler_ttvs'],
      cmdclass = {'build_ext': build_ext},
      classifiers=[
        'Development Status :: 4 - Beta',
        'Intended Audience :: Science/Research',
        'Operating System :: OS Independent',
        'Programming Language :: Python',
        'Topic :: Scientific/Engineering',
        'Topic :: Scientific/Engineering :: Astronomy'
        ],
      install_requires=['pandas>=0.13','simpledist>=0.1.11', 'emcee', 
                        'isochrones>=1.0', 'acor', 'numba>=0.20', 'batman-package>=2.1', 
                        'configobj'],
      zip_safe=False
) 

@@ -244,21 +244,17 @@
  = None%0A
-    
 %0A
+
 import o
@@ -1102,17 +1102,9 @@
 one%0A
-        
 %0A
+
 setu
@@ -1588,16 +1588,26 @@
  'tests/
+kepler-22/
 *.ini',%0A
@@ -1645,16 +1645,26 @@
  'tests/
+kepler-22/
 *.h5', '
@@ -1669,16 +1669,26 @@
  'tests/
+kepler-22/
 *.pkl',%0A
@@ -1726,16 +1726,26 @@
  'tests/
+kepler-22/
 *.cc'%5D,%0A
@@ -2556,17 +2556,16 @@
 'emcee',
- 
 %0A       
@@ -2645,17 +2645,16 @@
 e%3E=2.1',
- 
 %0A       
@@ -2705,11 +2705,10 @@
 e=False%0A
+
 )
- 
 %0A

add correct test data to package