# -*- coding: utf-8 -*-

from distutils.core import setup
from distutils.cmd import Command
from distutils import sysconfig
import os
import sys
import subprocess
import glob


from finpy import __version__

PACKAGE = "finpy"
NAME = "finpy"
DESCRIPTION = "finpy 0.2.0"
AUTHOR = "cheng li"
AUTHOR_EMAIL = "cheng.li@datayes.com"
URL = "www.datayes.com"
VERSION = __version__

if os.name == "posix":
  exePath = sys.path
  for path in exePath:
      if path.endswith('site-packages'):
          packagePath = path
          break
else:
    packagePath = sysconfig.get_python_lib()

files = glob.glob("finpy/tests/Risk/data/*.csv")
datafiles = [(os.path.join(packagePath, "finpy/tests/Risk/data"), files)]

class test(Command):
    description = "test the distribution prior to install"

    user_options = [
        ('test-dir=', None,
         "directory that contains the test definitions"),
        ]

    def initialize_options(self):
        self.test_dir = 'tests'

    def finalize_options(self):
        sys.path.insert(0, self.test_dir)

    def run(self):
        if sys.platform == 'win32':
            command = "coverage run finpy/tests/testSuite.py& coverage report& coverage html"
        else:
            command = "coverage run finpy/tests/testSuite.py; coverage report; coverage html"
        subprocess.Popen(command, shell=True)

setup(
    name=NAME,
    version=VERSION,
    description=DESCRIPTION,
    author=AUTHOR,
    author_email=AUTHOR_EMAIL,
    license="commercial",
    url=URL,
    packages=['finpy.API',
              'finpy.AlgoTrading',
              'finpy.DateUtilities',
              'finpy.Enums',
              'finpy.Env',
              'finpy.Math',
              'finpy.Math.Distributions',
              'finpy.PricingEngines',
              'finpy.Risk',
              'finpy.tests',
              'finpy.tests.API',
              'finpy.tests.DateUtilities',
              'finpy.tests.Env',
              'finpy.tests.Math',
              'finpy.tests.Risk',
              'finpy.tests.PricingEngines'
              ],
    py_modules=['finpy.__init__', 'finpy.tests.testSuite'],
    data_files=datafiles,
    classifiers=[
        "Development Status :: 3 - Alpha",
        "Environment :: PC test",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: BSD License",
        "Operating System :: OS Independent",
        "Programming Language :: Python 2.7/3.4",
        "Framework :: none",
    ],
    cmdclass={"test": test},
)
@@ -390,16 +390,18 @@
 posix%22:%0A
+  
   exePat
@@ -415,16 +415,18 @@
 .path%0A  
+ 
+ 
 for path
@@ -444,16 +444,18 @@
 :%0A      
+ 
+ 
 if path.
@@ -487,24 +487,26 @@
 :%0A          
+  
 packagePath 
@@ -508,24 +508,26 @@
 Path = path%0A
+  
           br
@@ -706,16 +706,17 @@
 iles)%5D%0A%0A
+%0A
 class te
@@ -1523,24 +1523,39 @@
   packages=%5B
+%0A              
 'finpy.API',

make formatting consistent