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
|
|
|
|
|
|
|
|
min_python = (2, 5)
|
|
|
|
if sys.version_info < min_python:
|
|
|
|
print "Darc requires Python %d.%d or later" % min_python
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if sys.version_info >= (3,):
|
|
|
|
print "Darc doesn't support Python 3 (yet)"
|
|
|
|
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
|
|
|
|
|
2012-02-29 22:30:24 +00:00
|
|
|
from distutils.core import setup
|
|
|
|
from distutils.extension import Extension
|
|
|
|
from distutils.command.sdist import sdist
|
2011-08-20 16:11:23 +00:00
|
|
|
hashindex_sources = ['darc/hashindex.pyx', 'darc/_hashindex.c']
|
2010-02-28 19:22:45 +00:00
|
|
|
|
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'):
|
|
|
|
print 'src', src
|
|
|
|
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.append('darc/hashindex.c')
|
|
|
|
self.filelist.append('darc/hashindex.h')
|
|
|
|
sdist.make_distribution(self)
|
2011-08-20 16:11:23 +00:00
|
|
|
|
|
|
|
except ImportError:
|
|
|
|
hashindex_sources[0] = hashindex_sources[0].replace('.pyx', '.c')
|
2012-02-29 22:30:24 +00:00
|
|
|
from distutils.command.build_ext import build_ext
|
2011-08-20 16:11:23 +00:00
|
|
|
Sdist = sdist
|
|
|
|
if not os.path.exists('darc/hashindex.c'):
|
|
|
|
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._speedups', ['darc/_speedups.c']),
|
2011-08-20 16:11:23 +00:00
|
|
|
Extension('darc.hashindex', hashindex_sources)],
|
2012-02-29 22:30:24 +00:00
|
|
|
scripts = ['scripts/darc'],
|
|
|
|
)
|
2010-04-18 20:08:12 +00:00
|
|
|
|