-
Notifications
You must be signed in to change notification settings - Fork 12
/
setup.py
164 lines (144 loc) · 5.43 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#! /usr/bin/env python
"""
Author: Sunil Thulasidasan
Setup script for SimX. For installating SimX, type
python setup.py install
or
python setup.py install --user
(this will install SimX under the user's home directory)
"""
from setuptools import setup#, find_packages, Extension
import distutils.command.build as _build
import setuptools.command.install as _install
import sys
import os
import os.path as op
import distutils.spawn as ds
import distutils.dir_util as dd
#import distutils
#import distutils.dist
#################
# CMake function
#################
#def run_cmake(cmake_args="-DSIMX_USE_PRIME=1 -DSIMX_USE_MPI=1"):
def run_cmake(use_prime=0,use_mpi=1):
"""
Runs CMake to determine configuration for this build
"""
if ds.find_executable('cmake') is None:
print "CMake is required to build SimX"
print "Please install cmake version >= 2.6 and re-run setup"
sys.exit(-1)
print "Configuring SimX build with CMake.... "
new_dir = op.join(op.split(__file__)[0],'build')
dd.mkpath(new_dir)
os.chdir(new_dir)
# construct argument string
cmake_args ="-DSIMX_USE_PRIME="+str(use_prime) \
+" -DSIMX_USE_MPI="+str(use_mpi)
try:
ds.spawn(['cmake','../']+cmake_args.split())
except ds.DistutilsExecError:
print "Error while running cmake"
print "run 'setup.py build --help' for build options"
print "You may also try editing the settings in CMakeLists.txt file and re-running setup"
sys.exit(-1)
###########################
# Custom 'install' command
###########################
class install(_install.install):
def run(self):
try:
import config as C
except ImportError:
cwd = os.getcwd()
run_cmake()
os.chdir(cwd)
import config as C
self.distribution.ext_modules = C.extension_list
# calling _install.install.run(self) does not fetch required packages
# and instead performs an old-style install. see command/install.py in
# setuptools. So, calling do_egg_install() manually here.
self.do_egg_install()
#########################
# Custom 'build' command
#########################
class build(_build.build):
user_options=_build.build.user_options + \
[('with-ssf',
None,
"Uses the miniSSF synchronization engine instead of SimX's native engine for message passing and synchronization."),
('without-mpi',
None,
"Build without MPI support. Parallel simulations are disabled in this case.")]
def initialize_options(self):
_build.build.initialize_options(self)
self.with_ssf = 0
self.without_mpi = 0
def run(self):
cwd = os.getcwd()
# if self.without_ssf and self.without_mpi:
# print "--without-ssf and --without-mpi cannot be used together"
# print "run setup.py build --help for options to build command"
# sys.exit(-1)
run_cmake(use_prime=self.with_ssf,
use_mpi = not self.without_mpi)
# if
# if self.without_ssf:
# run_cmake("-DSIMX_USE_PRIME=0")
# else:
# run_cmake()
#try:
# import config as C
# with open('build/src/minissf/ssf_config.h'): pass
#except (ImportError, IOError):
# either config.py file or ssf_config.h not found. Run CMake
os.chdir(cwd)
import config as C
# Now populate the extension module attribute.
self.distribution.ext_modules = C.extension_list
_build.build.run(self)
###################
# setup
###################
with open('README.txt') as file:
simx_long_desc = file.read()
setup(
name = "simx",
version = '0.3',
description = 'Parallel simulation library for Python',
requires = ["greenlet"],
install_requires = ["greenlet"],
include_package_data = True,
url = 'http://simx.lanl.gov',
author='Sunil Thulasidasan, Lukas Kroc and others',
author_email = '[email protected]',
maintainer_email = '[email protected]',
license = "GNU LGPL",
long_description = simx_long_desc,
keywords = "simulation, parallel simulation, distributed simulation, \
discrete event simulation, agent simulation, simulation library",
platforms = ['GNU/Linux','Unix','Mac OS-X'],
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.4',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Artificial Life',
'Topic :: Sociology',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: System :: Distributed Computing'],
# ext_modules is not present here. This will be generated through CMake via the
# build or install commands
cmdclass={'install':install,'build': build},
zip_safe=False,
packages = ['simx','simx.core','simx.os'],
)