borg/setup.py

62 lines
1.9 KiB
Python
Raw Normal View History

2010-02-28 19:22:45 +00:00
# -*- encoding: utf-8 *-*
#!/usr/bin/env python
2011-08-20 16:11:23 +00:00
import os
2010-10-30 11:24:23 +00:00
import sys
2011-08-20 16:11:23 +00:00
from glob import glob
2011-11-06 20:40:29 +00:00
import darc
2013-06-03 11:45:48 +00:00
min_python = (3, 2)
2011-11-06 20:40:29 +00:00
if sys.version_info < min_python:
2013-06-03 11:45:48 +00:00
print("Darc requires Python %d.%d or later" % min_python)
2011-11-06 20:40:29 +00:00
sys.exit(1)
2011-11-05 20:13:15 +00:00
try:
import Cython
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "fake_pyrex"))
except ImportError:
pass
from distutils.core import setup
from distutils.extension import Extension
from distutils.command.sdist import sdist
2010-02-28 19:22:45 +00:00
chunker_source = 'darc/chunker.pyx'
hashindex_source = 'darc/hashindex.pyx'
2011-08-20 16:11:23 +00:00
try:
from Cython.Distutils import build_ext
import Cython.Compiler.Main as cython_compiler
2011-11-06 20:40:29 +00:00
2011-08-20 16:11:23 +00:00
class Sdist(sdist):
def __init__(self, *args, **kwargs):
for src in glob('darc/*.pyx'):
cython_compiler.compile(glob('darc/*.pyx'),
cython_compiler.default_options)
sdist.__init__(self, *args, **kwargs)
2011-11-05 20:13:15 +00:00
def make_distribution(self):
self.filelist += ['darc/chunker.c', 'darc/chunker.h', 'darc/hashindex.c', 'darc/hashindex.h']
2011-11-05 20:13:15 +00:00
sdist.make_distribution(self)
2011-08-20 16:11:23 +00:00
except ImportError:
chunker_source = chunker_source.replace('.pyx', '.c')
hashindex_source = hashindex_source.replace('.pyx', '.c')
from distutils.command.build_ext import build_ext
2011-08-20 16:11:23 +00:00
Sdist = sdist
if not os.path.exists(chunker_source) or not os.path.exists(hashindex_source):
2011-08-20 16:11:23 +00:00
raise ImportError('The GIT version of darc needs Cython. Install Cython or use a released version')
2010-10-27 18:12:40 +00:00
setup(name='darc',
2011-11-06 20:40:29 +00:00
version=darc.__version__,
2011-06-23 20:49:16 +00:00
author='Jonas Borgström',
2010-02-28 19:22:45 +00:00
author_email='jonas@borgstrom.se',
2011-08-20 16:11:23 +00:00
url='http://github.com/jborg/darc/',
2010-10-27 18:12:40 +00:00
packages=['darc'],
2011-11-06 20:40:29 +00:00
cmdclass={'build_ext': build_ext, 'sdist': Sdist},
2010-12-16 19:23:22 +00:00
ext_modules=[
Extension('darc.chunker', [chunker_source]),
Extension('darc.hashindex', [hashindex_source])],
2013-05-28 12:35:55 +00:00
scripts=['scripts/darc'],
)
2010-04-18 20:08:12 +00:00