import versioneer

from setuptools import setup, find_packages

with open('requirements.txt') as f:
    required = f.read().splitlines()

with open('requirements-optional.txt') as f:
    optionals = f.read().splitlines()

reqs = []
links = []
for ir in required:
    if ir[0:3] == 'git':
        links += [ir + '#egg=' + ir.split('/')[-1] + '-0']
        reqs += [ir.split('/')[-1]]
    else:
        reqs += [ir]

opt_reqs = []
opt_links = []
extras_require = {}
for ir in optionals:
    # For conditionals like pytest=2.1; python == 3.6
    if ';' in ir:
        entries = ir.split(';')
        extras_require[entries[1]] = entries[0]
    # Git repos
    # This is still a bit of an issue because it can only catch
    # version not master
    if ir[0:3] == 'git':
        opt_links += [ir + '#egg=' + ir.split('/')[-1] + '-0']
        opt_reqs += [ir.split('/')[-1]]
    else:
        opt_reqs += [ir]
extras_require['extras'] = opt_reqs

setup(name='devito',
      version=versioneer.get_version(),
      cmdclass=versioneer.get_cmdclass(),
      description="Finite Difference DSL for symbolic computation.",
      long_description="""Devito is a new tool for performing
      optimised Finite Difference (FD) computation from high-level
      symbolic problem definitions. Devito performs automated code
      generation and Just-In-time (JIT) compilation based on symbolic
      equations defined in SymPy to create and execute highly
      optimised Finite Difference kernels on multiple computer
      platforms.""",
      url='http://www.devitoproject.org',
      author="Imperial College London",
      author_email='g.gorman@imperial.ac.uk',
      license='MIT',
      packages=find_packages(exclude=['docs', 'tests', 'examples']),
      install_requires=reqs,
      extras_require=extras_require,
      dependency_links=links,
      test_suite='tests')

@@ -225,27 +225,16 @@
 qs = %5B%5D%0A
-links = %5B%5D%0A
 for ir i
@@ -282,32 +282,14 @@
     
-links += %5Bir + '#egg=' +
+name =
  ir.
@@ -298,32 +298,24 @@
 lit('/')%5B-1%5D
- + '-0'%5D
 %0A        req
@@ -320,33 +320,45 @@
 eqs += %5B
-ir.split('/')%5B-1%5D
+'%25s @ %25s@master' %25 (name, ir)
 %5D%0A    el
@@ -401,23 +401,8 @@
  %5B%5D%0A
-opt_links = %5B%5D%0A
 extr
@@ -609,90 +609,17 @@
 epos
-%0A    # This is still a bit of an issue because it can only catch%0A    # version not
+, install
  mas
@@ -659,36 +659,14 @@
     
-opt_links += %5Bir + '#egg=' +
+name =
  ir.
@@ -683,16 +683,8 @@
 %5B-1%5D
- + '-0'%5D
 %0A   
@@ -701,33 +701,45 @@
 eqs += %5B
-ir.split('/')%5B-1%5D
+'%25s @ %25s@master' %25 (name, ir)
 %5D%0A    el
@@ -1676,38 +1676,8 @@
 re,%0A
-      dependency_links=links,%0A
     

update git url processing with latest syntax