setup.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # -*- encoding: utf-8 *-*
  2. #!/usr/bin/env python
  3. import os
  4. import sys
  5. from glob import glob
  6. import darc
  7. min_python = (3, 2)
  8. if sys.version_info < min_python:
  9. print("Darc requires Python %d.%d or later" % min_python)
  10. sys.exit(1)
  11. #from distutils.core import setup
  12. #from distutils.extension import Extension
  13. from setuptools import setup, Extension
  14. from distutils.command.sdist import sdist
  15. chunker_source = 'darc/chunker.pyx'
  16. hashindex_source = 'darc/hashindex.pyx'
  17. try:
  18. from Cython.Distutils import build_ext
  19. import Cython.Compiler.Main as cython_compiler
  20. class Sdist(sdist):
  21. def __init__(self, *args, **kwargs):
  22. for src in glob('darc/*.pyx'):
  23. cython_compiler.compile(glob('darc/*.pyx'),
  24. cython_compiler.default_options)
  25. sdist.__init__(self, *args, **kwargs)
  26. def make_distribution(self):
  27. self.filelist.extend(['darc/chunker.c', 'darc/_chunker.c', 'darc/hashindex.c', 'darc/_hashindex.c'])
  28. super(Sdist, self).make_distribution()
  29. except ImportError:
  30. class Sdist(sdist):
  31. def __init__(self, *args, **kwargs):
  32. raise Exception('Cython is required to run sdist')
  33. chunker_source = chunker_source.replace('.pyx', '.c')
  34. hashindex_source = hashindex_source.replace('.pyx', '.c')
  35. from distutils.command.build_ext import build_ext
  36. if not os.path.exists(chunker_source) or not os.path.exists(hashindex_source):
  37. raise ImportError('The GIT version of darc needs Cython. Install Cython or use a released version')
  38. setup(
  39. name='Darc',
  40. version=darc.__version__,
  41. author='Jonas Borgström',
  42. author_email='jonas@borgstrom.se',
  43. url='http://github.com/jborg/darc/',
  44. description='Deduplicating ARChiver written in Python',
  45. license='BSD',
  46. classifiers=[
  47. 'Development Status :: 4 - Beta',
  48. 'Environment :: Console',
  49. 'Intended Audience :: System Administrators',
  50. 'License :: OSI Approved :: BSD License',
  51. 'Operating System :: POSIX',
  52. 'Programming Language :: Python',
  53. 'Topic :: Security :: Cryptography',
  54. 'Topic :: System :: Archiving :: Backup',
  55. ],
  56. packages=['darc'],
  57. scripts=['scripts/darc'],
  58. cmdclass={'build_ext': build_ext, 'sdist': Sdist},
  59. ext_modules=[
  60. Extension('darc.chunker', [chunker_source]),
  61. Extension('darc.hashindex', [hashindex_source])
  62. ],
  63. install_requires=['msgpack-python', 'pyxattr']
  64. )