from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
import numpy as np
import os

extensions = [
    Extension("phantomas.mr_simul.fast_volume_fraction",
              ["phantomas/mr_simul/fast_volume_fraction.pyx",
               "phantomas/mr_simul/c_fast_volume_fraction.c"],
              include_dirs=[np.get_include(), "/usr/local/include/"],
              library_dirs=["/usr/lib/"],
              libraries=["gsl", "gslcblas"]),
]

setup(name='Phantomas',
      description='A software phantom generation tool for diffusion MRI.',
      version='0.1.dev',
      author='Emmanuel Caruyer',
      author_email='caruyer@gmail.com',
      url='http://www.emmanuelcaruyer.com/phantomas/',
      packages=['phantomas',
                'phantomas.geometry',
                'phantomas.mr_simul',
                'phantomas.utils',
                'phantomas.visu'],
      package_data={'phantomas.mr_simul': ["spherical_21_design.txt"]},
      scripts=[os.path.join('scripts', 'phantomas_struct'),
               os.path.join('scripts', 'phantomas_dwis'),
               os.path.join('scripts', 'phantomas_rois'),
               os.path.join('scripts', 'phantomas_masks'),
               os.path.join('scripts', 'phantomas_view')],
      # cmdclass={'build_ext': build_ext},
      ext_modules=cythonize(extensions),
      )

@@ -1,49 +1,176 @@
-from distutils.core import setup%0Afrom distuti
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0A%0Aimport os%0Aimport sys%0A%0Adef main():%0A    from glob import glob%0A    from setuptools import setup, find_packages%0A    from setuptoo
 ls.e
@@ -195,16 +195,21 @@
 tension%0A
+%0A    
 from Cyt
@@ -239,16 +239,20 @@
 ild_ext%0A
+    
 from Cyt
@@ -278,16 +278,20 @@
 thonize%0A
+    
 import n
@@ -305,19 +305,376 @@
  np%0A
-import os%0A%0A
+%0A    REQ_LINKS = %5B%5D%0A    with open('requirements.txt', 'r') as rfile:%0A        REQUIREMENTS = %5Bline.strip() for line in rfile.readlines()%5D%0A%0A    for i, req in enumerate(REQUIREMENTS):%0A        if req.startswith('-e'):%0A            REQUIREMENTS%5Bi%5D = req.split('=')%5B1%5D%0A            REQ_LINKS.append(req.split()%5B1%5D)%0A%0A    if REQUIREMENTS is None:%0A        REQUIREMENTS = %5B%5D%0A%0A    
 exte
@@ -688,16 +688,20 @@
 = %5B%0A    
+ 
+   
 Extensio
@@ -759,16 +759,20 @@
         
+    
 %5B%22phanto
@@ -826,16 +826,20 @@
         
+ 
+   
 %22phantom
@@ -874,24 +874,28 @@
 action.c%22%5D,%0A
+    
             
@@ -962,24 +962,28 @@
             
+  
+  
 library_dirs
@@ -994,24 +994,28 @@
 usr/lib/%22%5D,%0A
+    
             
@@ -1048,19 +1048,27 @@
 las%22%5D),%0A
-%5D%0A%0A
+    %5D%0A%0A    
 setup(na
@@ -1079,24 +1079,28 @@
 Phantomas',%0A
+    
       descri
@@ -1168,16 +1168,20 @@
 ,%0A      
+    
 version=
@@ -1191,16 +1191,20 @@
 1.dev',%0A
+    
       au
@@ -1230,24 +1230,28 @@
 yer',%0A      
+    
 author_email
@@ -1272,16 +1272,20 @@
 l.com',%0A
+    
       ur
@@ -1333,24 +1333,28 @@
 as/',%0A      
+    
 packages=%5B'p
@@ -1354,168 +1354,29 @@
 ges=
-%5B'phantomas',%0A                'phantomas.geometry',%0A                'phantomas.mr_simul',%0A                'phantomas.utils',%0A                'phantomas.visu'%5D,%0A
+find_packages(),%0A    
     
@@ -1453,16 +1453,20 @@
     
+    
 scripts=
 %5Bos.
@@ -1465,50 +1465,23 @@
 pts=
-%5Bos.path.join('scripts', 'phantomas_struct
+glob('scripts/*
 '),%0A
@@ -1494,320 +1494,261 @@
     
-   
-  os.path.join('scripts', 'phantomas_dwis'),%0A               os.path.join('scripts', 'phantomas_rois'),%0A               os.path.join('scripts', 'phantomas_masks'),%0A               os.path.join('scripts', 'phantomas_view')%5D,%0A      # cmdclass=%7B'build_ext': build_ext%7D,%0A      ext_modules=cythonize(extensions),%0A      
+# cmdclass=%7B'build_ext': build_ext%7D,%0A          ext_modules=cythonize(extensions),%0A          )%0A%0Aif __name__ == '__main__':%0A    LOCAL_PATH = os.path.dirname(os.path.abspath(sys.argv%5B0%5D))%0A    os.chdir(LOCAL_PATH)%0A    sys.path.insert(0, LOCAL_PATH)%0A%0A    main(
 )%0A

Use distutils instead of setuptools