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.
This commit is contained in:
Jim Paris 2019-08-29 14:46:31 -04:00
parent 90ee127c87
commit d8df6f515f
6 changed files with 31 additions and 50 deletions

1
.gitignore vendored
View File

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

View File

@ -6,9 +6,13 @@ include versioneer.py
include Makefile
include .coveragerc
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
exclude nilmdb/server/interval.c
exclude nilmdb/server/rbtree.c
# Version
include nilmdb/_version.py

View File

@ -37,7 +37,7 @@ clean::
find . -name '*.pyc' -o -name '__pycache__' -print0 | xargs -0 rm -rf
rm -f .coverage
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
gitclean::

View File

@ -4,9 +4,14 @@ by Jim Paris <jim@jtan.com>
Prerequisites:
# 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
Test:

View File

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

View File

@ -9,15 +9,8 @@
import traceback
import sys
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.
# https://github.com/warner/python-versioneer
@ -28,32 +21,22 @@ import versioneer
try: import multiprocessing
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' ]) ]
# Use Cython.
cython_modules = [ 'nilmdb.server.interval', 'nilmdb.server.rbtree' ]
import Cython
from Cython.Build import cythonize
for modulename in cython_modules:
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
setup(name='nilmdb',
@ -65,21 +48,8 @@ setup(name='nilmdb',
long_description = "NILM Database",
license = "Proprietary",
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',
'nilmdb.utils',
'nilmdb.server',