2013-01-29 20:21:03 -05:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2013-02-05 18:49:07 -05:00
|
|
|
# To release a new version, tag it:
|
|
|
|
# git tag -a nilmdb-1.1 -m "Version 1.1"
|
|
|
|
# git push --tags
|
|
|
|
# Then just package it up:
|
|
|
|
# python setup.py sdist
|
|
|
|
|
2013-01-29 20:21:03 -05:00
|
|
|
# This is supposed to be using Distribute:
|
|
|
|
#
|
|
|
|
# distutils provides a "setup" method.
|
|
|
|
# setuptools is a set of monkeypatches on top of that.
|
|
|
|
# distribute is a particular version/implementation of setuptools.
|
|
|
|
#
|
|
|
|
# So we don't really know if this is using the old setuptools or the
|
|
|
|
# Distribute-provided version of setuptools.
|
|
|
|
|
2013-02-01 17:44:50 -05:00
|
|
|
import traceback
|
|
|
|
import sys
|
2013-02-04 22:12:50 -05:00
|
|
|
import os
|
2013-01-30 18:35:12 -05:00
|
|
|
|
2013-02-01 17:44:50 -05:00
|
|
|
try:
|
|
|
|
from setuptools import setup, find_packages
|
|
|
|
from distutils.extension import Extension
|
2013-02-04 22:12:50 -05:00
|
|
|
import distutils.version
|
2013-02-01 17:44:50 -05:00
|
|
|
except ImportError:
|
|
|
|
traceback.print_exc()
|
|
|
|
print "Please install the prerequisites listed in README.txt"
|
|
|
|
sys.exit(1)
|
2013-01-29 20:21:03 -05:00
|
|
|
|
2013-02-05 18:49:07 -05:00
|
|
|
# Versioneer manages version numbers from git tags.
|
|
|
|
# https://github.com/warner/python-versioneer
|
|
|
|
import versioneer
|
|
|
|
versioneer.versionfile_source = 'nilmdb/_version.py'
|
|
|
|
versioneer.versionfile_build = 'nilmdb/_version.py'
|
|
|
|
versioneer.tag_prefix = 'nilmdb-'
|
|
|
|
versioneer.parentdir_prefix = 'nilmdb-'
|
|
|
|
|
2013-01-30 18:35:12 -05:00
|
|
|
# Hack to workaround logging/multiprocessing issue:
|
|
|
|
# https://groups.google.com/d/msg/nose-users/fnJ-kAUbYHQ/_UsLN786ygcJ
|
|
|
|
try: import multiprocessing
|
2013-03-24 21:28:01 -04:00
|
|
|
except Exception: pass
|
2013-01-30 18:35:12 -05:00
|
|
|
|
2013-02-04 22:12:50 -05:00
|
|
|
# Use Cython if it's new enough, otherwise use preexisting C files.
|
|
|
|
cython_modules = [ 'nilmdb.server.interval',
|
|
|
|
'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
|
|
|
|
|
2013-03-03 16:54:11 -05:00
|
|
|
ext_modules = [ Extension('nilmdb.server.rocket', ['nilmdb/server/rocket.c' ]) ]
|
2013-02-04 22:12:50 -05:00
|
|
|
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 ]))
|
2013-02-04 18:14:44 -05:00
|
|
|
|
|
|
|
# We need a MANIFEST.in. Generate it here rather than polluting the
|
|
|
|
# repository with yet another setup-related file.
|
|
|
|
with open("MANIFEST.in", "w") as m:
|
|
|
|
m.write("""
|
|
|
|
# Root
|
|
|
|
include README.txt
|
|
|
|
include setup.cfg
|
|
|
|
include setup.py
|
2013-02-05 18:49:07 -05:00
|
|
|
include versioneer.py
|
2013-02-04 18:14:44 -05:00
|
|
|
include Makefile
|
|
|
|
include .coveragerc
|
|
|
|
include .pylintrc
|
|
|
|
|
|
|
|
# Cython files -- include source.
|
|
|
|
recursive-include nilmdb/server *.pyx *.pyxdep *.pxd
|
|
|
|
|
|
|
|
# Tests
|
|
|
|
recursive-include tests *.py
|
|
|
|
recursive-include tests/data *
|
|
|
|
include tests/test.order
|
|
|
|
|
|
|
|
# Docs
|
|
|
|
recursive-include docs Makefile *.md
|
2013-03-15 15:08:28 -04:00
|
|
|
|
|
|
|
# Extras
|
|
|
|
recursive-include extras *
|
2013-02-04 18:14:44 -05:00
|
|
|
""")
|
2013-01-29 20:21:03 -05:00
|
|
|
|
|
|
|
# Run setup
|
|
|
|
setup(name='nilmdb',
|
2013-02-05 18:49:07 -05:00
|
|
|
version = versioneer.get_version(),
|
|
|
|
cmdclass = versioneer.get_cmdclass(),
|
2013-01-31 17:14:47 -05:00
|
|
|
url = 'https://git.jim.sh/jim/lees/nilmdb.git',
|
|
|
|
author = 'Jim Paris',
|
2013-02-04 18:14:44 -05:00
|
|
|
description = "NILM Database",
|
|
|
|
long_description = "NILM Database",
|
|
|
|
license = "Proprietary",
|
2013-01-31 17:14:47 -05:00
|
|
|
author_email = 'jim@jtan.com',
|
2013-01-30 18:35:12 -05:00
|
|
|
tests_require = [ 'nose',
|
|
|
|
'coverage',
|
2013-04-07 18:04:59 -04:00
|
|
|
'numpy',
|
2013-01-30 18:35:12 -05:00
|
|
|
],
|
2013-02-04 22:12:50 -05:00
|
|
|
setup_requires = [ 'distribute',
|
|
|
|
],
|
|
|
|
install_requires = [ 'decorator',
|
2013-02-01 15:29:24 -05:00
|
|
|
'cherrypy >= 3.2',
|
2013-02-04 22:14:09 -05:00
|
|
|
'simplejson',
|
|
|
|
'python-dateutil',
|
|
|
|
'pytz',
|
2013-02-14 16:57:33 -05:00
|
|
|
'psutil >= 0.3.0',
|
2013-02-26 21:56:29 -05:00
|
|
|
'requests >= 1.1.0, < 2.0.0',
|
2013-01-30 18:35:12 -05:00
|
|
|
],
|
|
|
|
packages = [ 'nilmdb',
|
|
|
|
'nilmdb.utils',
|
2013-01-31 17:25:14 -05:00
|
|
|
'nilmdb.utils.datetime_tz',
|
2013-01-30 18:35:12 -05:00
|
|
|
'nilmdb.server',
|
|
|
|
'nilmdb.client',
|
|
|
|
'nilmdb.cmdline',
|
2013-02-01 17:42:09 -05:00
|
|
|
'nilmdb.scripts',
|
2013-01-30 18:35:12 -05:00
|
|
|
],
|
2013-02-01 16:23:13 -05:00
|
|
|
entry_points = {
|
|
|
|
'console_scripts': [
|
2013-02-01 17:42:09 -05:00
|
|
|
'nilmtool = nilmdb.scripts.nilmtool:main',
|
2013-02-01 17:43:41 -05:00
|
|
|
'nilmdb-server = nilmdb.scripts.nilmdb_server:main',
|
2013-02-01 16:23:13 -05:00
|
|
|
],
|
|
|
|
},
|
2013-02-04 22:12:50 -05:00
|
|
|
ext_modules = ext_modules,
|
2013-01-30 18:35:12 -05:00
|
|
|
zip_safe = False,
|
2013-01-29 20:21:03 -05:00
|
|
|
)
|