setup.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # -*- encoding: utf-8 *-*
  2. import os
  3. import sys
  4. from glob import glob
  5. import attic
  6. import versioneer
  7. versioneer.versionfile_source = 'attic/_version.py'
  8. versioneer.versionfile_build = 'attic/_version.py'
  9. versioneer.tag_prefix = ''
  10. versioneer.parentdir_prefix = 'Attic-' # dirname like 'myproject-1.2.0'
  11. min_python = (3, 2)
  12. if sys.version_info < min_python:
  13. print("Attic requires Python %d.%d or later" % min_python)
  14. sys.exit(1)
  15. try:
  16. from setuptools import setup, Extension
  17. except ImportError:
  18. from distutils.core import setup, Extension
  19. chunker_source = 'attic/chunker.pyx'
  20. hashindex_source = 'attic/hashindex.pyx'
  21. try:
  22. from Cython.Distutils import build_ext
  23. import Cython.Compiler.Main as cython_compiler
  24. class Sdist(versioneer.cmd_sdist):
  25. def __init__(self, *args, **kwargs):
  26. for src in glob('attic/*.pyx'):
  27. cython_compiler.compile(glob('attic/*.pyx'),
  28. cython_compiler.default_options)
  29. versioneer.cmd_sdist.__init__(self, *args, **kwargs)
  30. def make_distribution(self):
  31. self.filelist.extend(['attic/chunker.c', 'attic/_chunker.c', 'attic/hashindex.c', 'attic/_hashindex.c'])
  32. super(Sdist, self).make_distribution()
  33. except ImportError:
  34. class Sdist(versioneer.cmd_sdist):
  35. def __init__(self, *args, **kwargs):
  36. raise Exception('Cython is required to run sdist')
  37. chunker_source = chunker_source.replace('.pyx', '.c')
  38. hashindex_source = hashindex_source.replace('.pyx', '.c')
  39. from distutils.command.build_ext import build_ext
  40. if not os.path.exists(chunker_source) or not os.path.exists(hashindex_source):
  41. raise ImportError('The GIT version of attic needs Cython. Install Cython or use a released version')
  42. with open('README.rst', 'r') as fd:
  43. long_description = fd.read()
  44. cmdclass = versioneer.get_cmdclass()
  45. cmdclass.update({'build_ext': build_ext, 'sdist': Sdist})
  46. setup(
  47. name='Attic',
  48. version=versioneer.get_version(),
  49. author='Jonas Borgström',
  50. author_email='jonas@borgstrom.se',
  51. url='https://pythonhosted.org/Attic/',
  52. description='Deduplicated backups',
  53. long_description=long_description,
  54. license='BSD',
  55. platforms=['Linux', 'MacOS X'],
  56. classifiers=[
  57. 'Development Status :: 4 - Beta',
  58. 'Environment :: Console',
  59. 'Intended Audience :: System Administrators',
  60. 'License :: OSI Approved :: BSD License',
  61. 'Operating System :: POSIX :: BSD :: FreeBSD',
  62. 'Operating System :: MacOS :: MacOS X',
  63. 'Operating System :: POSIX :: Linux',
  64. 'Programming Language :: Python',
  65. 'Topic :: Security :: Cryptography',
  66. 'Topic :: System :: Archiving :: Backup',
  67. ],
  68. packages=['attic', 'attic.testsuite'],
  69. scripts=['scripts/attic'],
  70. cmdclass=cmdclass,
  71. ext_modules=[
  72. Extension('attic.chunker', [chunker_source]),
  73. Extension('attic.hashindex', [hashindex_source])
  74. ],
  75. install_requires=['msgpack-python']
  76. )