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.
 
 
 

115 lines
3.3 KiB

  1. #!/usr/bin/python
  2. # This is supposed to be using Distribute:
  3. #
  4. # distutils provides a "setup" method.
  5. # setuptools is a set of monkeypatches on top of that.
  6. # distribute is a particular version/implementation of setuptools.
  7. #
  8. # So we don't really know if this is using the old setuptools or the
  9. # Distribute-provided version of setuptools.
  10. import traceback
  11. import sys
  12. import os
  13. try:
  14. from setuptools import setup, find_packages
  15. from distutils.extension import Extension
  16. import distutils.version
  17. except ImportError:
  18. traceback.print_exc()
  19. print "Please install the prerequisites listed in README.txt"
  20. sys.exit(1)
  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: pass
  25. # Use Cython if it's new enough, otherwise use preexisting C files.
  26. cython_modules = [ 'nilmdb.server.interval',
  27. 'nilmdb.server.layout',
  28. 'nilmdb.server.rbtree' ]
  29. try:
  30. import Cython
  31. from Cython.Build import cythonize
  32. if (distutils.version.LooseVersion(Cython.__version__) <
  33. distutils.version.LooseVersion("0.16")):
  34. print "Cython version", Cython.__version__, "is too old; not using it."
  35. raise ImportError()
  36. use_cython = True
  37. except ImportError:
  38. use_cython = False
  39. ext_modules = []
  40. for modulename in cython_modules:
  41. filename = modulename.replace('.','/')
  42. if use_cython:
  43. ext_modules.extend(cythonize(filename + ".pyx"))
  44. else:
  45. cfile = filename + ".c"
  46. if not os.path.exists(cfile):
  47. raise Exception("Missing source file " + cfile + ". "
  48. "Try installing cython >= 0.16.")
  49. ext_modules.append(Extension(modulename, [ cfile ]))
  50. # We need a MANIFEST.in. Generate it here rather than polluting the
  51. # repository with yet another setup-related file.
  52. with open("MANIFEST.in", "w") as m:
  53. m.write("""
  54. # Root
  55. include README.txt
  56. include setup.cfg
  57. include setup.py
  58. include Makefile
  59. include .coveragerc
  60. include .pylintrc
  61. # Cython files -- include source.
  62. recursive-include nilmdb/server *.pyx *.pyxdep *.pxd
  63. # Tests
  64. recursive-include tests *.py
  65. recursive-include tests/data *
  66. include tests/test.order
  67. # Docs
  68. recursive-include docs Makefile *.md
  69. """)
  70. # Run setup
  71. setup(name='nilmdb',
  72. version = '1.0',
  73. url = 'https://git.jim.sh/jim/lees/nilmdb.git',
  74. author = 'Jim Paris',
  75. description = "NILM Database",
  76. long_description = "NILM Database",
  77. license = "Proprietary",
  78. author_email = 'jim@jtan.com',
  79. tests_require = [ 'nose',
  80. 'coverage',
  81. ],
  82. setup_requires = [ 'distribute',
  83. ],
  84. install_requires = [ 'decorator',
  85. 'cherrypy >= 3.2',
  86. ],
  87. packages = [ 'nilmdb',
  88. 'nilmdb.utils',
  89. 'nilmdb.utils.datetime_tz',
  90. 'nilmdb.server',
  91. 'nilmdb.client',
  92. 'nilmdb.cmdline',
  93. 'nilmdb.scripts',
  94. ],
  95. entry_points = {
  96. 'console_scripts': [
  97. 'nilmtool = nilmdb.scripts.nilmtool:main',
  98. 'nilmdb-server = nilmdb.scripts.nilmdb_server:main',
  99. ],
  100. },
  101. ext_modules = ext_modules,
  102. zip_safe = False,
  103. )