# -*- encoding: utf-8 *-*
#!/usr/bin/env python
import sys
from setuptools import setup, Extension
from Cython.Distutils import build_ext

dependencies = ['pycrypto', 'msgpack-python', 'pbkdf2.py', 'xattr', 'paramiko', 'Pyrex', 'Cython']
if sys.version_info < (2, 7):
    dependencies.append('argparse')


setup(name='darc',
      version='0.1',
      author='Jonas Borgström',
      author_email='jonas@borgstrom.se',
      packages=['darc'],
      cmdclass = {'build_ext': build_ext},
      ext_modules=[
      Extension('darc._speedups', ['darc/_speedups.c']),
                   Extension('darc.hashindex', ['darc/hashindex.pyx', 'darc/_hashindex.c'])],
      install_requires=dependencies,
      entry_points = {
        'console_scripts': [
            'darc = darc.archiver:main',
        ]
    })


@@ -48,19 +48,51 @@
 %0Aimport 
-sys
+os%0Aimport sys%0Afrom glob import glob
 %0Afrom se
@@ -133,41 +133,981 @@
 rom 
-Cython.Distutils import build_ext
+setuptools.command.sdist import sdist%0Ahashindex_sources = %5B'darc/hashindex.pyx', 'darc/_hashindex.c'%5D%0A%0Atry:%0A    from Cython.Distutils import build_ext%0A    import Cython.Compiler.Main as cython_compiler%0A    class Sdist(sdist):%0A        def __init__(self, *args, **kwargs):%0A            for src in glob('darc/*.pyx'):%0A                print 'src', src%0A                cython_compiler.compile(glob('darc/*.pyx'),%0A                                        cython_compiler.default_options)%0A            sdist.__init__(self, *args, **kwargs)%0A%0A        def run(self):%0A            sdist.run(self)%0A            self.filelist.append('darc/hashindex.c', 'darc/hashindex.h')%0A%0Aexcept ImportError:%0A    hashindex_sources%5B0%5D = hashindex_sources%5B0%5D.replace('.pyx', '.c')%0A    from setuptools.command.build_ext import build_ext%0A    Sdist = sdist%0A    if not os.path.exists('darc/hashindex.c'):%0A        raise ImportError('The GIT version of darc needs Cython. Install Cython or use a released version')
 %0A%0Ade
@@ -1186,27 +1186,8 @@
 iko'
-, 'Pyrex', 'Cython'
 %5D%0Aif
@@ -1365,16 +1365,59 @@
 om.se',%0A
+      url='http://github.com/jborg/darc/',%0A
       pa
@@ -1473,16 +1473,32 @@
 uild_ext
+, 'sdist': Sdist
 %7D,%0A     
@@ -1569,29 +1569,16 @@
 s.c'%5D),%0A
-             
       Ex
@@ -1603,23 +1603,16 @@
 index', 
-%5B'darc/
 hashinde
@@ -1616,35 +1616,16 @@
 ndex
-.pyx', 'darc/_hashindex.c'%5D
+_sources
 )%5D,%0A

Include Cython output in sdist