import os
from setuptools import setup


os.chdir(os.path.abspath(os.path.dirname(__file__)))


packages = []
for rootdir, dirs, files in os.walk('vistrails'):
    if '__init__.py' in files:
        packages.append(rootdir.replace('\\', '.').replace('/', '.'))


def list_files(d, root):
    files = []
    for e in os.listdir(os.path.join(root, d)):
        if os.path.isdir(os.path.join(root, d, e)):
            files.extend(list_files('%s/%s' % (d, e), root))
        elif not e.endswith('.pyc'):
            files.append('%s/%s' % (d, e))
    return files


package_data = {
    'vistrails.core.collection': ['schema.sql', 'test.db'],
    'vistrails.core': list_files('resources', 'vistrails/core'),
    'vistrails.db': ['specs/all.xml'],
    'vistrails.gui': list_files('resources/images', 'vistrails/gui') + ['resources/vistrails-mime.xml'],
    'vistrails.packages.analytics': ['*.vt'], # FIXME : what is this?
    'vistrails.packages.CLTools': ['icons/*.png', 'test_files/*'],
    'vistrails.packages.persistence': ['schema.sql'],
    'vistrails.packages.tabledata': ['test_files/*'],
    'vistrails.tests': list_files('resources', 'vistrails/tests'),
    }
for version in os.listdir('vistrails/db/versions'):
    if not version.startswith('v'):
        continue
    package_data['vistrails.db.versions.%s' % version] = [
        'schemas/sql/vistrails.sql',
        'schemas/sql/vistrails_drop.sql',
        'schemas/xml/log.xsd',
        'schemas/xml/vistrail.xsd',
        'schemas/xml/vtlink.xsd',
        'schemas/xml/workflow.xsd',
        'specs/all.xml',
]


description = """
VisTrails is an open-source data analysis and visualization tool. It provides a comprehensive provenance infrastructure that maintains detailed history information about the steps followed and data derived in the course of an exploratory task: VisTrails maintains provenance of data products, of the computational processes that derive these products and their executions.

For more information, take a look at the [documentation](http://www.vistrails.org/index.php/Documentation), the [users guide](http://www.vistrails.org/usersguide/v2.0/html/), or our [publications](http://www.vistrails.org/index.php/Publications,_Tutorials_and_Presentations).

Binary releases are available on our [download](http://www.vistrails.org/index.php/Downloads) page. To report bugs, please use the github [issue](https://github.com/VisTrails/VisTrails/issues) tracker, after checking our [FAQ](http://www.vistrails.org/index.php/FAQ) for known issues.

Homepage: <http://www.vistrails.org>

Who we are: <http://www.vistrails.org/index.php/People>
"""
setup(name='vistrails',
      version='2.1.2',
      packages=packages,
      package_data=package_data,
      entry_points={
        'console_scripts': [
          'vistrails = vistrails.run:main']},
      zip_safe=False,
      install_requires=[
        # 'PyQt<5.0',
        'numpy',
        'scipy'],
      description='Data analysis and visualization tool',
      author="New York University",
      author_email='vistrails-dev@vistrails.org',
      url='http://www.vistrails.org/',
      long_description=description,
      license='BSD',
      keywords=['vistrails', 'provenance', 'visualization', 'vtk', 'nyu',
                'matplotlib', ],
      classifiers=[
        'Development Status :: 5 - Production/Stable',
        'Intended Audience :: Science/Research',
        'License :: OSI Approved :: BSD License',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 2 :: Only',
        'Topic :: Scientific/Engineering',
        'Topic :: Scientific/Engineering :: Information Analysis',
        'Topic :: Scientific/Engineering :: Visualization'])

@@ -2002,17 +2002,17 @@
  at the 
-%5B
+%60
 document
@@ -2016,18 +2016,18 @@
 entation
-%5D(
+ %3C
 http://w
@@ -2070,16 +2070,18 @@
 tion
-)
+%3E%60_
 , the 
-%5B
+%60
 user
@@ -2087,18 +2087,18 @@
 rs guide
-%5D(
+ %3C
 http://w
@@ -2135,17 +2135,19 @@
 .0/html/
-)
+%3E%60_
 , or our
@@ -2147,17 +2147,17 @@
  or our 
-%5B
+%60
 publicat
@@ -2160,18 +2160,18 @@
 ications
-%5D(
+ %3C
 http://w
@@ -2238,17 +2238,19 @@
 ntations
-)
+%3E%60_
 .%0A%0ABinar
@@ -2285,17 +2285,17 @@
 our 
-%5B
+%60
 download
 %5D(ht
@@ -2290,18 +2290,18 @@
 download
-%5D(
+ %3C
 http://w
@@ -2336,17 +2336,19 @@
 ownloads
-)
+%3E%60_
  page. T
@@ -2388,16 +2388,24 @@
 hub 
-%5B
+%60
 issue
-%5D(
+ tracker %3C
 http
@@ -2449,17 +2449,11 @@
 sues
-) tracker
+%3E%60_
 , af
@@ -2473,14 +2473,14 @@
 our 
-%5BFAQ%5D(
+%60FAQ %3C
 http
@@ -2513,17 +2513,19 @@
 .php/FAQ
-)
+%3E%60_
  for kno
@@ -2546,17 +2546,16 @@
 mepage: 
-%3C
 http://w
@@ -2570,17 +2570,16 @@
 ails.org
-%3E
 %0A%0AWho we
@@ -2584,17 +2584,16 @@
 we are: 
-%3C
 http://w
@@ -2625,17 +2625,16 @@
 p/People
-%3E
 %0A%22%22%22%0Aset

Converts long_description to rst format