#!/usr/bin/env python
"""
$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/dulcinea/setup.py $
$Id: setup.py 31066 2008-09-10 14:16:21Z dbinger $

Setup script for Dulcinea
"""
from distutils import core
from distutils.extension import Extension
unused = Extension # for import checker.  Extension import is for side effect.
try:
    from qpy.setup import qpy_build_py
except ImportError:
    print("Please install Qpy first.")
    raise SystemExit
from lib.__init__ import __version__
import re, sys, os

if 'sdist' in sys.argv:
    if sys.platform == 'darwin':
        # Omit extended attributes from tarfile
        os.environ['COPYFILE_DISABLE'] = 'true'
    # Make sure that version numbers have all been updated.
    PAT = re.compile(r'\b%s\b' % re.escape(__version__))
    assert len(PAT.findall(open("LICENSE.txt").read())) == 12, __version__
    assert PAT.search(open("CHANGES.txt").readline()), __version__
    assert len(PAT.findall(open("README.txt").read())) == 1, __version__

    # Make sure that copyright statements are current.
    from datetime import datetime
    year = datetime.now().year # no tz, ok
    copyright = "Copyright (c) Corporation for National Research Initiatives %s" % year
    assert open("README.txt").read().count(copyright) == 1

kw = {'name': "Dulcinea",
      'version': __version__,
      'description': ("A package of modules useful for developing "
                      "QP/Durus applications."),
      'author': "CNRI",
      'author_email': "webmaster@mems-exchange.org",
      'url': "http://www.mems-exchange.org/software/dulcinea/",
      'license': "see LICENSE.txt",

      'package_dir': {'dulcinea':'lib'},
      'packages': ['dulcinea',
                   'dulcinea.ui',
                   'dulcinea.ui.lib',
                   'dulcinea.ui.form',
                   'dulcinea.ui.user'],
      'scripts': ['bin/expire_session.py'],
      'cmdclass': {'build_py': qpy_build_py},
     }

# If we're running Python 2.3, add extra information
if hasattr(core, 'setup_keywords'):
    if 'classifiers' in core.setup_keywords:
        kw['classifiers'] = ['Development Status :: 3 - Alpha',
          'Intended Audience :: Developers',
          'Operating System :: Unix',
          'Topic :: Software Development :: Libraries',
          ]
    if 'download_url' in core.setup_keywords:
        kw['download_url'] = ('http://www.mems-exchange.org/software/files'
                              '/dulcinea/Dulcinea-%s.tar.gz' % kw['version'])

core.setup(**kw)
