You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

setup.py 3.8 KiB

9 years ago
9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/usr/bin/python
  2. # To release a new version, tag it:
  3. # git tag -a nilmdb-1.1 -m "Version 1.1"
  4. # git push --tags
  5. # Then just package it up:
  6. # python setup.py sdist
  7. import traceback
  8. import sys
  9. import os
  10. try:
  11. from setuptools import setup, find_packages
  12. from distutils.extension import Extension
  13. import distutils.version
  14. except ImportError:
  15. traceback.print_exc()
  16. print("Please install the prerequisites listed in README.txt")
  17. sys.exit(1)
  18. # Versioneer manages version numbers from git tags.
  19. # https://github.com/warner/python-versioneer
  20. import versioneer
  21. # Hack to workaround logging/multiprocessing issue:
  22. # https://groups.google.com/d/msg/nose-users/fnJ-kAUbYHQ/_UsLN786ygcJ
  23. try: import multiprocessing
  24. except Exception: pass
  25. # Use Cython if it's new enough, otherwise use preexisting C files.
  26. cython_modules = [ 'nilmdb.server.interval',
  27. 'nilmdb.server.rbtree' ]
  28. try:
  29. import Cython
  30. from Cython.Build import cythonize
  31. if (distutils.version.LooseVersion(Cython.__version__) <
  32. distutils.version.LooseVersion("0.16")):
  33. print("Cython version", Cython.__version__, "is too old; not using it.")
  34. raise ImportError()
  35. use_cython = True
  36. except ImportError:
  37. use_cython = False
  38. ext_modules = [ Extension('nilmdb.server.rocket', ['nilmdb/server/rocket.c' ]) ]
  39. for modulename in cython_modules:
  40. filename = modulename.replace('.','/')
  41. if use_cython:
  42. ext_modules.extend(cythonize(filename + ".pyx"))
  43. else:
  44. cfile = filename + ".c"
  45. if not os.path.exists(cfile):
  46. raise Exception("Missing source file " + cfile + ". "
  47. "Try installing cython >= 0.16.")
  48. ext_modules.append(Extension(modulename, [ cfile ]))
  49. # We need a MANIFEST.in. Generate it here rather than polluting the
  50. # repository with yet another setup-related file.
  51. with open("MANIFEST.in", "w") as m:
  52. m.write("""
  53. # Root
  54. include README.txt
  55. include setup.cfg
  56. include setup.py
  57. include versioneer.py
  58. include Makefile
  59. include .coveragerc
  60. include .pylintrc
  61. # Cython files -- include source.
  62. recursive-include nilmdb/server *.pyx *.pyxdep *.pxd
  63. # Version
  64. include nilmdb/_version.py
  65. # Tests
  66. recursive-include tests *.py
  67. recursive-include tests/data *
  68. include tests/test.order
  69. # Docs
  70. recursive-include docs Makefile *.md
  71. # Extras
  72. recursive-include extras *
  73. """)
  74. # Run setup
  75. setup(name='nilmdb',
  76. version = versioneer.get_version(),
  77. cmdclass = versioneer.get_cmdclass(),
  78. url = 'https://git.jim.sh/jim/lees/nilmdb.git',
  79. author = 'Jim Paris',
  80. description = "NILM Database",
  81. long_description = "NILM Database",
  82. license = "Proprietary",
  83. author_email = 'jim@jtan.com',
  84. tests_require = [ 'nose',
  85. 'coverage',
  86. 'numpy',
  87. ],
  88. setup_requires = [ 'setuptools',
  89. ],
  90. install_requires = [ 'decorator',
  91. 'cherrypy >= 3.2',
  92. 'simplejson',
  93. 'python-dateutil',
  94. 'pytz',
  95. 'psutil >= 0.3.0',
  96. 'requests >= 1.1.0',
  97. 'progressbar >= 2.2',
  98. ],
  99. packages = [ 'nilmdb',
  100. 'nilmdb.utils',
  101. 'nilmdb.server',
  102. 'nilmdb.client',
  103. 'nilmdb.cmdline',
  104. 'nilmdb.scripts',
  105. 'nilmdb.fsck',
  106. ],
  107. entry_points = {
  108. 'console_scripts': [
  109. 'nilmtool = nilmdb.scripts.nilmtool:main',
  110. 'nilmdb-server = nilmdb.scripts.nilmdb_server:main',
  111. 'nilmdb-fsck = nilmdb.scripts.nilmdb_fsck:main',
  112. ],
  113. },
  114. ext_modules = ext_modules,
  115. zip_safe = False,
  116. )