setup.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # -*- encoding: utf-8 *-*
  2. import os
  3. import sys
  4. from glob import glob
  5. import darc
  6. min_python = (3, 2)
  7. if sys.version_info < min_python:
  8. print("Darc requires Python %d.%d or later" % min_python)
  9. sys.exit(1)
  10. try:
  11. from setuptools import setup, Extension
  12. except ImportError:
  13. from distutils.core 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. with open('README.rst', 'r') as fd:
  39. long_description = fd.read()
  40. setup(
  41. name='darc',
  42. version=darc.__release__,
  43. author='Jonas Borgström',
  44. author_email='jonas@borgstrom.se',
  45. url='http://github.com/jborg/darc/',
  46. description='Deduplicating ARChiver written in Python',
  47. long_description=long_description,
  48. license='BSD',
  49. platforms=['Linux', 'MacOS X'],
  50. classifiers=[
  51. 'Development Status :: 4 - Beta',
  52. 'Environment :: Console',
  53. 'Intended Audience :: System Administrators',
  54. 'License :: OSI Approved :: BSD License',
  55. 'Operating System :: MacOS :: MacOS X',
  56. 'Operating System :: POSIX :: Linux',
  57. 'Programming Language :: Python',
  58. 'Topic :: Security :: Cryptography',
  59. 'Topic :: System :: Archiving :: Backup',
  60. ],
  61. packages=['darc', 'darc.testsuite'],
  62. scripts=['scripts/darc'],
  63. cmdclass={'build_ext': build_ext, 'sdist': Sdist},
  64. ext_modules=[
  65. Extension('darc.chunker', [chunker_source]),
  66. Extension('darc.hashindex', [hashindex_source])
  67. ],
  68. install_requires=['msgpack-python']
  69. )