Browse Source

Update setup.py and build instructions

This is a pretty big simplification: the user should first use pip to
install everything in `requirements.txt`, and we no longer try to
cater to cases where Cython is missing, etc.
tags/nilmdb-2.0.0
Jim Paris 4 years ago
parent
commit
d8df6f515f
6 changed files with 31 additions and 50 deletions
  1. +1
    -0
      .gitignore
  2. +5
    -1
      MANIFEST.in
  3. +1
    -1
      Makefile
  4. +7
    -2
      README.txt
  5. +1
    -0
      requirements.txt
  6. +16
    -46
      setup.py

+ 1
- 0
.gitignore View File

@@ -15,6 +15,7 @@ nilmdb/server/rbtree.c
# Setup junk # Setup junk
dist/ dist/
nilmdb.egg-info/ nilmdb.egg-info/
venv/


# Misc # Misc
timeit*out timeit*out


+ 5
- 1
MANIFEST.in View File

@@ -6,9 +6,13 @@ include versioneer.py
include Makefile include Makefile
include .coveragerc include .coveragerc
include .pylintrc include .pylintrc
include requirements.txt


# Cython files -- include source.
# Cython files -- include .pyx source, but not the generated .c files
# (Downstream systems must have cython installed in order to build)
recursive-include nilmdb/server *.pyx *.pyxdep *.pxd recursive-include nilmdb/server *.pyx *.pyxdep *.pxd
exclude nilmdb/server/interval.c
exclude nilmdb/server/rbtree.c


# Version # Version
include nilmdb/_version.py include nilmdb/_version.py


+ 1
- 1
Makefile View File

@@ -37,7 +37,7 @@ clean::
find . -name '*.pyc' -o -name '__pycache__' -print0 | xargs -0 rm -rf find . -name '*.pyc' -o -name '__pycache__' -print0 | xargs -0 rm -rf
rm -f .coverage rm -f .coverage
rm -rf tests/*testdb* rm -rf tests/*testdb*
rm -rf nilmdb.egg-info/ build/ nilmdb/server/*.so MANIFEST.in
rm -rf nilmdb.egg-info/ build/ nilmdb/server/*.so
make -C docs clean make -C docs clean


gitclean:: gitclean::


+ 7
- 2
README.txt View File

@@ -4,9 +4,14 @@ by Jim Paris <jim@jtan.com>
Prerequisites: Prerequisites:


# Runtime and build environments # Runtime and build environments
sudo apt install python3.7 python3.7-dev python3-pip
sudo apt install python3.7 python3.7-dev python3.7-venv python3-pip


# Install NilmDB dependencies
# Optional: create a new Python virtual environment to isolate
# dependencies. To leave the virtual environment, run "deactivate"
python -m venv venv
source venv/bin/activate

# Install all Python dependencies from PyPI.
pip3 install -r requirements.txt pip3 install -r requirements.txt


Test: Test:


+ 1
- 0
requirements.txt View File

@@ -1,3 +1,4 @@
cython>=0.29.13
CherryPy>=18.1.2 CherryPy>=18.1.2
coverage>=4.5.4 coverage>=4.5.4
decorator>=4.4.0 decorator>=4.4.0


+ 16
- 46
setup.py View File

@@ -9,15 +9,8 @@
import traceback import traceback
import sys import sys
import os import os

try:
from setuptools import setup, find_packages
from distutils.extension import Extension
import distutils.version
except ImportError:
traceback.print_exc()
print("Please install the prerequisites listed in README.txt")
sys.exit(1)
from setuptools import setup
from distutils.extension import Extension


# Versioneer manages version numbers from git tags. # Versioneer manages version numbers from git tags.
# https://github.com/warner/python-versioneer # https://github.com/warner/python-versioneer
@@ -28,32 +21,22 @@ import versioneer
try: import multiprocessing try: import multiprocessing
except Exception: pass except Exception: pass


# 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

# External modules that need to be built
ext_modules = [ Extension('nilmdb.server.rocket', ['nilmdb/server/rocket.c' ]) ] ext_modules = [ Extension('nilmdb.server.rocket', ['nilmdb/server/rocket.c' ]) ]

# Use Cython.
cython_modules = [ 'nilmdb.server.interval', 'nilmdb.server.rbtree' ]
import Cython
from Cython.Build import cythonize
for modulename in cython_modules: for modulename in cython_modules:
filename = modulename.replace('.','/') 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 ]))
ext_modules.extend(cythonize(filename + ".pyx"))


# Get list of requirements to use in `install_requires` below. Note
# that we don't make a distinction between things that are actually
# required for end-users vs developers (or use `test_requires` or
# anything else) -- just install everything for simplicity.
install_requires = open('requirements.txt').readlines()


# Run setup # Run setup
setup(name='nilmdb', setup(name='nilmdb',
@@ -65,21 +48,8 @@ setup(name='nilmdb',
long_description = "NILM Database", long_description = "NILM Database",
license = "Proprietary", license = "Proprietary",
author_email = 'jim@jtan.com', author_email = 'jim@jtan.com',
tests_require = [ 'nose',
'coverage',
'numpy',
],
setup_requires = [ 'setuptools',
],
install_requires = [ 'decorator',
'cherrypy >= 3.2',
'simplejson',
'python-dateutil',
'pytz',
'psutil >= 0.3.0',
'requests >= 1.1.0',
'progressbar >= 2.2',
],
setup_requires = [ 'setuptools' ],
install_requires = install_requires,
packages = [ 'nilmdb', packages = [ 'nilmdb',
'nilmdb.utils', 'nilmdb.utils',
'nilmdb.server', 'nilmdb.server',


Loading…
Cancel
Save