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.
 
 
 

137 lines
4.2 KiB

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