#!/usr/bin/env python3
"""
imcalc : fits image calculator using reverse polish notation
"""

## BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
## update it when the contents of directories change.

#import os
#if os.path.exists('MANIFEST'):
#    os.remove('MANIFEST')

#from distutils.core import setup

# setuptools to allow 'python setup.py develop'. Not necessary for user.
try:
    from setuptools import setup
except ImportError:
    pass

from datetime import datetime

MAJOR = 0
MINOR = 1
ATTR = 'dev'
VERSION = '%d.%d%s' % (MAJOR, MINOR, ATTR)


## Is this needed?
def write_version_py(filename='imcalc/version.py'):
    '''Write version file'''
    cnt = """
# THIS FILE GENERATED BY SIMCADO SETUP.PY
version = '{}'
date    = '{}'
"""
    timestamp = datetime.utcnow().strftime('%Y-%m-%d %T GMT')
    with open(filename, 'w') as fd1:
        fd1.write(cnt.format(VERSION, timestamp))


def setup_package():
    '''Setup the package'''
    write_version_py()

    setup(name='imcalc',
          version=VERSION,
          description="FITS image calculator",
          author="Oliver Czoske",
          author_email="oliver.czoske@univie.ac.at",
          package_dir={'imcalc': 'imcalc'},
          packages=['imcalc']
          # for some reason include_package_data can be temperamental
          #include_package_data=True,
          #package_data = {'simcado': ['data/*']},
         )


if __name__ == '__main__':
    setup_package()
