borg/setup.py

59 lines
1.8 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
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.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')
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=[
2013-05-28 12:35:55 +00:00
Extension('darc.chunker', ['darc/chunker.pyx']),
Extension('darc.hashindex', ['darc/hashindex.pyx'])],
scripts=['scripts/darc'],
)
2010-04-18 20:08:12 +00:00