Newer
Older
# -*- coding: utf-8 -*-
scripts prepare MOOSE for PyPI.
Last modified: Mon Jul 28, 2014 12:52AM
"""
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
__author__ = "Dilawar Singh"
__copyright__ = "Copyright 2013, Dilawar Singh and NCBS Bangalore"
__credits__ = ["NCBS Bangalore"]
__license__ = "GNU GPL"
__version__ = "1.0.0"
__maintainer__ = "Dilawar Singh"
__email__ = "dilawars@ncbs.res.in"
__status__ = "Development"
import os
import sys
import shutil
from setuptools import setup
from distutils.core import Command, Extension
from distutils.command.install import install as _install
from distutils.command.build import build as _build
from distutils.command.build_py import build_py as _build_py
import distutils.spawn as ds
build_dir = 'buildMooseUsingCmake'
if not os.path.isdir(build_dir):
os.makedirs(build_dir)
class BuildCommand(_build):
"""This command builds """
user_options = _build.user_options + []
def initialize_options(self):
self.cwd = os.getcwd()
self.build_base = '/tmp'
self.build_temp = '/tmp'
self.build_lib = '/tmp'
self.new_dir = os.path.join(os.path.split(__file__)[0], build_dir)
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
def finalize_options(self):
pass
def get_source_files(self):
return []
def run(self):
print("++ Building MOOSE")
os.chdir(self.new_dir)
try:
ds.spawn(['cmake', '..' ])
ds.spawn(['make', '_moose'])
except ds.DistutilsExecError as e:
print("Can't build MOOSE")
print(e)
os.chdir(self.cwd)
sys.exit(-1)
os.chdir(self.cwd)
class InstallCommand(_install):
user_options = _install.user_options + [
('single-version-externally-managed', None, '')
]
def initialize_options(self):
_install.initialize_options(self)
self.cwd = os.getcwd()
self.single_version_externally_managed = False
self.record = None
self.build_lib = None
def finalize_options(self):
_install.finalize_options(self)
def run(self):
self.new_dir = os.path.join(os.path.split(__file__)[0], build_dir)
os.chdir(self.new_dir)
try:
ds.spawn(['cmake', '..' ])
ds.spawn(['make', '_moose'])
except ds.DistutilsExecError as e:
print("Can't build MOOSE")
print(e)
os.chdir(self.cwd)
sys.exit(-1)
os.chdir(self.cwd)
print("++ Installing PyMOOSE")
self.new_dir = os.path.join(os.path.split(__file__)[0], 'python')
os.chdir(self.new_dir)
try:
ds.spawn(["python", "setup.cmake.py", "install"])
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
except ds.DistutilsExecError as e:
print("Can't install PyMOOSE")
print(e)
os.chdir(self.cwd)
sys.exit(-1)
os.chdir(self.cwd)
class BuildPyCommand(_build_py):
"""Build PyMoose for distribution"""
user_options = _build_py.user_options + [
( 'build_lib', None, 'Build library' )
]
def initialize_options(self):
self.data_files = []
self.build_lib = '/tmp'
self.cwd = os.getcwd()
self.compiler = None
self.new_dir = os.path.join(os.path.split(__file__)[0], 'python')
def finalize_options(self):
pass
def run(self):
pass
##
# @brief FUnction to read a file.
#
# @param fname Name of the file.
#
# @return A string content of the file.
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
name = 'moose'
version = '3.0'
description = (
'MOOSE is the Multiscale Object-Oriented Simulation Environment. '
'It is the base and numerical core for large, detailed simulations '
'including Computational Neuroscience and Systems Biology.' )
url = 'http://moose.ncbs.res.in/'
setup(
name = name
, version = version
, author = "Upinder Bhalla et. al."
, author_email = "bhalla@ncbs.res.in"
, maintainer = 'Dilawar Singh'
, maintainer_email = 'dilawars@ncbs.res.in'
, description = description
, license = "LGPL"
, url = url
, long_description = read('./README.md')
, ext_modules = [
Extension('_moose', [ '*' ])
]
'install' : InstallCommand
, 'build_py' : BuildPyCommand
, 'build_ext' : BuildCommand
}
, require = [ 'python-qt4' ]
, keywords = "neural simulation"
, classifiers=[
'Intended Audience :: Science/Research',
'Operating System :: Linux',
'Programming Language :: Python',
'Programming Language :: C++',
]
)