setup.py 2.5 KB

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