setup.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # -*- encoding: utf-8 *-*
  2. import os
  3. import sys
  4. from glob import glob
  5. import attic
  6. min_python = (3, 2)
  7. if sys.version_info < min_python:
  8. print("Attic 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 = 'attic/chunker.pyx'
  16. hashindex_source = 'attic/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('attic/*.pyx'):
  23. cython_compiler.compile(glob('attic/*.pyx'),
  24. cython_compiler.default_options)
  25. sdist.__init__(self, *args, **kwargs)
  26. def make_distribution(self):
  27. self.filelist.extend(['attic/chunker.c', 'attic/_chunker.c', 'attic/hashindex.c', 'attic/_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 attic 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='Attic',
  42. version=attic.__release__,
  43. author='Jonas Borgström',
  44. author_email='jonas@borgstrom.se',
  45. url='https://pythonhosted.org/Attic/',
  46. description='Deduplicated backups',
  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 :: POSIX :: BSD :: FreeBSD',
  56. 'Operating System :: MacOS :: MacOS X',
  57. 'Operating System :: POSIX :: Linux',
  58. 'Programming Language :: Python',
  59. 'Topic :: Security :: Cryptography',
  60. 'Topic :: System :: Archiving :: Backup',
  61. ],
  62. packages=['attic', 'attic.testsuite'],
  63. scripts=['scripts/attic'],
  64. cmdclass={'build_ext': build_ext, 'sdist': Sdist},
  65. ext_modules=[
  66. Extension('attic.chunker', [chunker_source]),
  67. Extension('attic.hashindex', [hashindex_source])
  68. ],
  69. install_requires=['msgpack-python']
  70. )