forked from simomarsili/ndd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
114 lines (100 loc) · 3.69 KB
/
setup.py
File metadata and controls
114 lines (100 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# -*- coding: utf-8 -*-
"""Setup module."""
# pylint: disable=wrong-import-position
from __future__ import print_function
from pkg_resources import parse_version
NAME = 'ndd'
NUMPY_MIN_VERSION = '1.9'
VERSION_FILE = 'version.json'
SETUP_REQUIRES = ['numpy>=1.9']
INSTALL_REQUIRES = []
EXTRAS_REQUIRES = {'test': ['pytest']}
def get_numpy_status():
"""
Returns a dictionary containing a boolean specifying whether NumPy
is up-to-date, along with the version string (empty string if
not installed).
From pymc: https://raw.githubusercontent.com/pymc-devs/pymc/master/setup.py
"""
status = {}
try:
import numpy
numpy_version = numpy.__version__
status['up_to_date'] = parse_version(numpy_version) >= parse_version(
NUMPY_MIN_VERSION)
status['version'] = numpy_version
except ImportError:
status['up_to_date'] = False
status['version'] = ''
return status
def get_version(source):
""" Retrieve version number."""
import json
with open(source, 'r') as _vf:
version_data = json.load(_vf)
try:
return version_data['version']
except KeyError:
raise KeyError('check version file: no version number')
def get_long_description():
"""Get the long description from the README file."""
from os import path
import codecs
here = path.abspath(path.dirname(__file__))
with codecs.open(path.join(here, 'README.rst'), encoding='utf-8') as _rf:
return _rf.read()
# check numpy first
NUMPY_STATUS = get_numpy_status()
NUMPY_REQ_STR = "ndd requires NumPy >= %s. Run 'pip install -U numpy' " % NUMPY_MIN_VERSION
if NUMPY_STATUS['up_to_date'] is False:
if NUMPY_STATUS['version']:
raise ImportError('Your installation of NumPy %s is out-of-date.\n%s' %
(NUMPY_STATUS['version'], NUMPY_REQ_STR))
raise ImportError('NumPy is not installed.\n%s' % NUMPY_REQ_STR)
from numpy.distutils.core import Extension # isort:skip
from numpy.distutils.core import setup # isort:skip
VERSION = get_version(VERSION_FILE)
LONG_DESCRIPTION = get_long_description()
FNSB = Extension(
name='ndd.fnsb',
sources=[
'ndd/nsb.pyf', 'ndd/exts/gamma.f90', 'ndd/exts/quad.f90',
'ndd/exts/estimators.f90'
],
# extra_f90_compile_args = ["-fopenmp"],
# extra_link_args = ["-lgomp"],
)
setup(
name=NAME,
version=VERSION,
description='Bayesian entropy estimation from discrete data',
long_description=LONG_DESCRIPTION,
# long_description_content_type="text/markdown",
author='Simone Marsili',
author_email='simo.marsili@gmail.com',
url='https://github.com/simomarsili/ndd',
keywords='entropy estimation Bayes discrete_data',
data_files=[(NAME, ['ndd/version.json'])],
packages=['ndd'],
package_data={'': ['LICENSE.txt', 'README.rst', 'requirements.txt']},
ext_modules=[FNSB],
python_requires='>=3.4',
setup_requires=SETUP_REQUIRES,
install_requires=INSTALL_REQUIRES,
extras_require={'test': ['pytest']},
license='BSD 3-Clause',
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Scientific/Engineering :: Information Analysis',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
)