#!/usr/bin/env python

"""Setup script for NasT."""

import sys, os

from distutils.core import setup, Extension
#from distutils.extension import Extension
#from distutils.command.build_ext import build_ext

if sys.version_info[:2] < (2, 2):
    print "NasT requires Python 2.2 or better.  Python %d.%d detected" % \
          sys.version_info[:2]
    sys.exit(-1)

try :
    import Numeric
except :
    raise SystemExit, "The Numeric package is required for NasT " + \
          "downloadable from http://numpy.sourceforge.net/"

try:
    f = open('buildNum.txt')
    buildNum=int(f.read())
    f.close()
except IOError:
    buildNum=0

if sys.argv[1].find('sdist')>=0:
    buildNum+=1
version = "0.3.%d" % buildNum

f = open('buildNum.txt', 'w')
f.write('%d' % buildNum)
f.close()

f = open('nast/version.py', 'w')
f.write('buildNum = %d\n' % buildNum)
f.write('version = "%s"' % version)
f.close()

setupKeywords = {}
setupKeywords["name"]              = "nast"
setupKeywords["version"]           = version
setupKeywords["author"]            = "Randall J. Radmer"
setupKeywords["author_email"]      = "radmer@stanford.edu"
setupKeywords["license"]           = "Python Software Foundation License (BSD-like)"
setupKeywords["url"]               = "https://simtk.org/projects/nast"
setupKeywords["platforms"]         = "Linux/Unix-like"
setupKeywords["description"]       = "nast - a python MD package"
setupKeywords["long_description"]  = \
"""NasT is a collection of python modules for performing
molecular dynamics (MD) simulations.  It includes python
code to do assignment and dynamic adjustment of parameters,
python code to manage integration steps (using numpy),
and C code to calculate energies and forces for typical
energy functions.  This package is intended for (but not
limited to) Go Model type simulations.
"""

setupKeywords["packages"] = ["nast", "nast.md", "tools"]

ext_source_files =  ["nast/paramarrays.c"]

ext_source_files_md =  ["nast/md/gosimbase.c",
                        "nast/md/arrayops.c",
                        "nast/md/calcall.c",
                        "nast/md/calcrestraints.c",
                        "nast/md/calcarbitraries.c",
                        "nast/md/calcbonds.c",
                        "nast/md/calcangles.c",
                        "nast/md/calcdihedrals.c",
                        "nast/md/calcr1.c",
                        "nast/md/calcr12.c",
                        "nast/md/calcr6r12.c",
                        "nast/md/calcr10r12.c",
                        "nast/md/calcspread.c",
                        "nast/md/vec.c",
                        "nast/md/cubicsplinecalc.c"
                       ]
setupKeywords["ext_modules"] = [Extension("nast.paramarrays",
                                          ext_source_files,
                                          include_dirs=["nast"]),
                                Extension("nast.md.gosimbase",
                                          ext_source_files_md,
                                          include_dirs=["nast",
                                                        "nast/md"]),
                                ]

setup(**setupKeywords)


