setup.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # -*- encoding: utf-8 *-*
  2. #!/usr/bin/env python
  3. import os
  4. import sys
  5. from glob import glob
  6. try:
  7. import Cython
  8. sys.path.insert(0, os.path.join(os.path.dirname(__file__), "fake_pyrex"))
  9. except ImportError:
  10. pass
  11. from setuptools import setup, Extension
  12. from setuptools.command.sdist import sdist
  13. hashindex_sources = ['darc/hashindex.pyx', 'darc/_hashindex.c']
  14. try:
  15. from Cython.Distutils import build_ext
  16. import Cython.Compiler.Main as cython_compiler
  17. class Sdist(sdist):
  18. def __init__(self, *args, **kwargs):
  19. for src in glob('darc/*.pyx'):
  20. print 'src', src
  21. cython_compiler.compile(glob('darc/*.pyx'),
  22. cython_compiler.default_options)
  23. sdist.__init__(self, *args, **kwargs)
  24. def make_distribution(self):
  25. self.filelist.append('darc/hashindex.c')
  26. self.filelist.append('darc/hashindex.h')
  27. sdist.make_distribution(self)
  28. except ImportError:
  29. hashindex_sources[0] = hashindex_sources[0].replace('.pyx', '.c')
  30. from setuptools.command.build_ext import build_ext
  31. Sdist = sdist
  32. if not os.path.exists('darc/hashindex.c'):
  33. raise ImportError('The GIT version of darc needs Cython. Install Cython or use a released version')
  34. dependencies = ['pycrypto', 'msgpack-python', 'pbkdf2.py', 'xattr', 'paramiko']
  35. if sys.version_info < (2, 7):
  36. dependencies.append('argparse')
  37. setup(name='darc',
  38. version='0.1',
  39. author='Jonas Borgström',
  40. author_email='jonas@borgstrom.se',
  41. url='http://github.com/jborg/darc/',
  42. packages=['darc'],
  43. cmdclass = {'build_ext': build_ext, 'sdist': Sdist},
  44. ext_modules=[
  45. Extension('darc._speedups', ['darc/_speedups.c']),
  46. Extension('darc.hashindex', hashindex_sources)],
  47. install_requires=dependencies,
  48. entry_points = {
  49. 'console_scripts': [
  50. 'darc = darc.archiver:main',
  51. ]
  52. })