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.
 
 
 

142 lines
4.3 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 Exception: pass
  37. # Use Cython if it's new enough, otherwise use preexisting C files.
  38. cython_modules = [ 'nilmdb.server.interval',
  39. 'nilmdb.server.rbtree' ]
  40. try:
  41. import Cython
  42. from Cython.Build import cythonize
  43. if (distutils.version.LooseVersion(Cython.__version__) <
  44. distutils.version.LooseVersion("0.16")):
  45. print "Cython version", Cython.__version__, "is too old; not using it."
  46. raise ImportError()
  47. use_cython = True
  48. except ImportError:
  49. use_cython = False
  50. ext_modules = [ Extension('nilmdb.server.rocket', ['nilmdb/server/rocket.c' ]) ]
  51. for modulename in cython_modules:
  52. filename = modulename.replace('.','/')
  53. if use_cython:
  54. ext_modules.extend(cythonize(filename + ".pyx"))
  55. else:
  56. cfile = filename + ".c"
  57. if not os.path.exists(cfile):
  58. raise Exception("Missing source file " + cfile + ". "
  59. "Try installing cython >= 0.16.")
  60. ext_modules.append(Extension(modulename, [ cfile ]))
  61. # We need a MANIFEST.in. Generate it here rather than polluting the
  62. # repository with yet another setup-related file.
  63. with open("MANIFEST.in", "w") as m:
  64. m.write("""
  65. # Root
  66. include README.txt
  67. include setup.cfg
  68. include setup.py
  69. include versioneer.py
  70. include Makefile
  71. include .coveragerc
  72. include .pylintrc
  73. # Cython files -- include source.
  74. recursive-include nilmdb/server *.pyx *.pyxdep *.pxd
  75. # Tests
  76. recursive-include tests *.py
  77. recursive-include tests/data *
  78. include tests/test.order
  79. # Docs
  80. recursive-include docs Makefile *.md
  81. # Extras
  82. recursive-include extras *
  83. """)
  84. # Run setup
  85. setup(name='nilmdb',
  86. version = versioneer.get_version(),
  87. cmdclass = versioneer.get_cmdclass(),
  88. url = 'https://git.jim.sh/jim/lees/nilmdb.git',
  89. author = 'Jim Paris',
  90. description = "NILM Database",
  91. long_description = "NILM Database",
  92. license = "Proprietary",
  93. author_email = 'jim@jtan.com',
  94. tests_require = [ 'nose',
  95. 'coverage',
  96. 'numpy',
  97. ],
  98. setup_requires = [ 'distribute',
  99. ],
  100. install_requires = [ 'decorator',
  101. 'cherrypy >= 3.2',
  102. 'simplejson',
  103. 'python-dateutil',
  104. 'pytz',
  105. 'psutil >= 0.3.0',
  106. 'requests >= 1.1.0',
  107. 'progressbar >= 2.2',
  108. ],
  109. packages = [ 'nilmdb',
  110. 'nilmdb.utils',
  111. 'nilmdb.utils.datetime_tz',
  112. 'nilmdb.server',
  113. 'nilmdb.client',
  114. 'nilmdb.cmdline',
  115. 'nilmdb.scripts',
  116. 'nilmdb.fsck',
  117. ],
  118. entry_points = {
  119. 'console_scripts': [
  120. 'nilmtool = nilmdb.scripts.nilmtool:main',
  121. 'nilmdb-server = nilmdb.scripts.nilmdb_server:main',
  122. 'nilmdb-fsck = nilmdb.scripts.nilmdb_fsck:main',
  123. ],
  124. },
  125. ext_modules = ext_modules,
  126. zip_safe = False,
  127. )