forked from robince/pyentropy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
88 lines (70 loc) · 2.68 KB
/
setup.py
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
import sys, os
import pyentropy
# BEFORE importing disutils, remove MANIFEST. distutils doesn't properly
# update it when the contents of directories change.
if os.path.exists('MANIFEST'): os.remove('MANIFEST')
from distutils.core import setup
from distutils.extension import Extension
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError, DistutilsExecError
extension_build_failed = False
def ext_failed_warning(name):
print ('*'*70+'\n')*3
print """WARNING: The %s extension module could not be
compiled. pyEntropy should run, but the features
present in that file will not be available.
Above is the ouput showing how the compilation
failed."""%name
if sys.platform == 'win32':
print
print """I see you are using Windows. The default
compiler for this platform is the Microsoft Visual
Studio C compiler. However, a free alternative
compiler called mingw can be used instead."""
print
print ('*'*70+'\n')*3
global extension_build_failed
extension_build_failed = True
try:
from gsl_dist.gsl_Extension import gsl_Extension
except DistutilsExecError:
ext_failed_warning('gsl-based')
exts = []
wrap_sources = ['hist_c.c', 'sort_c.c', 'gen_c.c', 'entropy_c.c',
'entropy_nsb_c.cpp', 'entropy_bub_c.c', 'wrap.c']
statk_wrap_sources = [os.path.join('pyentropy','statk',x) for x in wrap_sources]
try:
statk_wrap = gsl_Extension("statk.wrap",
sources = statk_wrap_sources,
gsl_min_version=(1,),
python_min_version=(2,5)
)
exts.append(statk_wrap)
except:
pass
class build_ext_allow_fail( build_ext ):
# This class allows C extension building to fail.
# Taken from visionegg (LGPL)
# http://github.com/visionegg/visionegg/blob/master/setup.py
# http://www.visionegg.org/
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except CCompilerError, x:
ext_failed_warning(ext.name)
setup(name='pyentropy',
version=pyentropy.__version__,
description='Entropy and Information Theoretic Estimates',
author=pyentropy.__author__,
author_email='[email protected]',
url='http://code.google.com/p/pyentropy',
packages=['pyentropy','pyentropy.tests','pyentropy.statk'],
ext_package='pyentropy',
ext_modules=exts,
cmdclass={'build_ext':build_ext_allow_fail}
)
if extension_build_failed:
print ('*'*70+'\n')*3
print """WARNING: Building of some extensions failed. Please
see the messages above for details.\n"""
print ('*'*70+'\n')*3