forked from DEAP/deap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
91 lines (78 loc) · 3.05 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
88
89
90
91
#!/usr/bin/env python
import sys
from distutils.core import setup, Extension
try:
from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
from distutils.command.build_py import build_py
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError, DistutilsExecError, \
DistutilsPlatformError
import deap
if sys.platform == 'win32' and sys.version_info > (2, 6):
# 2.6's distutils.msvc9compiler can raise an IOError when failing to
# find the compiler
# It can also raise ValueError http://bugs.python.org/issue7511
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError,
IOError, ValueError)
else:
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
class BuildFailed(Exception):
pass
class ve_build_ext(build_ext):
# This class allows C extension building to fail.
def run(self):
try:
build_ext.run(self)
except DistutilsPlatformError:
raise BuildFailed()
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except ext_errors:
raise BuildFailed()
def run_setup(build_ext):
extra_modules = None
if build_ext:
extra_modules = list()
hv_module = Extension("deap.tools.hv", sources=["deap/tools/_hv.c", "deap/tools/hv.cpp"])
extra_modules.append(hv_module)
setup(name='deap',
version=deap.__revision__,
description='Distributed Evolutionary Algorithms in Python',
long_description=open('README.txt').read(),
author='deap Development Team',
author_email='[email protected]',
url='http://deap.googlecode.com',
packages=['deap', 'deap.tools', 'deap.benchmarks', 'deap.tests'],
platforms=['any'],
keywords=['evolutionary algorithms','genetic algorithms','genetic programming','cma-es','ga','gp','es','pso'],
license='LGPL',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering',
'Topic :: Software Development',
],
ext_modules = extra_modules,
cmdclass = {'build_py': build_py, "build_ext" : ve_build_ext}
)
try:
run_setup(True)
except BuildFailed:
print("*" * 75)
print("WARNING: The C extensions could not be compiled, "
"speedups won't be available.")
print("Now building without C extensions.")
print("*" * 75)
run_setup(False)
print("*" * 75)
print("WARNING: The C extensions could not be compiled, "
"speedups won't be available.")
print("Plain-Python installation succeeded.")
print("*" * 75)