@@ -11,11 +11,12 @@
import traceback
import sys
import os
try:
from setuptools import setup, find_packages
from distutils.extension import Extension
from Cython.Build import cythonize
import distutils.version
except ImportError:
traceback.print_exc()
print "Please install the prerequisites listed in README.txt"
@@ -26,15 +27,32 @@ except ImportError:
try: import multiprocessing
except: pass
if len(sys.argv) == 2 and sys.argv[1] == 'sdist':
# When building just a source distribution package, skip Cython,
# so that the generated .c files don't get included. This isn't
# foolproof, but the worst case is that the .c files get included,
# which is fine.
cython_modules = []
else:
# Build cython modules.
cython_modules = cythonize("**/*.pyx")
# Use Cython if it's new enough, otherwise use preexisting C files.
cython_modules = [ 'nilmdb.server.interval',
'nilmdb.server.layout',
'nilmdb.server.rbtree' ]
try:
import Cython
from Cython.Build import cythonize
if (distutils.version.LooseVersion(Cython.__version__) <
distutils.version.LooseVersion("0.16")):
print "Cython version", Cython.__version__, "is too old; not using it."
raise ImportError()
use_cython = True
except ImportError:
use_cython = False
ext_modules = []
for modulename in cython_modules:
filename = modulename.replace('.','/')
if use_cython:
ext_modules.extend(cythonize(filename + ".pyx"))
else:
cfile = filename + ".c"
if not os.path.exists(cfile):
raise Exception("Missing source file " + cfile + ". "
"Try installing cython >= 0.16.")
ext_modules.append(Extension(modulename, [ cfile ]))
# We need a MANIFEST.in. Generate it here rather than polluting the
# repository with yet another setup-related file.
@@ -72,10 +90,9 @@ setup(name='nilmdb',
tests_require = [ 'nose',
'coverage',
],
setup_requires = [ 'cython',
],
install_requires = [ 'distribute',
'decorator',
setup_requires = [ 'distribute',
],
install_requires = [ 'decorator',
'cherrypy >= 3.2',
],
packages = [ 'nilmdb',
@@ -92,6 +109,6 @@ setup(name='nilmdb',
'nilmdb-server = nilmdb.scripts.nilmdb_server:main',
],
},
ext_modules = cython _modules,
ext_modules = ext _modules,
zip_safe = False,
)