-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
executable file
·220 lines (165 loc) · 6.41 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# ***************************************************************************
# * *
# * AFLOWpi - Central Michigan University University, 2017 *
# * *
# ***************************************************************************
#
# Copyright 2017 - Andrew Supka and Marco Fornari - AFLOW.ORG consortium
#
# This file is part of AFLOW software.
#
# AFLOW is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# ***************************************************************************
#import setuptools
import sys
import os
#import setuptools
from setuptools import setup, Command,Extension
# distutils.core import setup, Command,Extension
#from distutils.util import change_root, convert_path
#from distutils.command.install import install
import shutil
sys.path.append(os.path.curdir)
import site
from src.prep.src.prep import __version__ as version
#os.environ["CC"] = "gcc"
#os.environ["CXX"] = "g++"
#ext_modules=
import glob
import re
import os
import inspect
orig_dir=os.path.abspath(os.curdir)
def __init__gen(src_folder):
os.chdir('%s'%src_folder)
files = glob.glob('./*.py')
new_file=''
for i in files:
try:
if '__init__'!=i[2:-3]:
with open(i,'r') as pypy:
py_string = pypy.read()
file_name=os.path.basename(i)[:-3]
functions = re.findall(r'^def\s*(\w+)\(.*\):',py_string,re.M)
for j in functions:
new_file+='from .%s import %s\n'%(file_name,j)
classes = re.findall(r'^class (\w+)(?:\(.*?\))?:',py_string,re.M)
for j in classes:
new_file+='from .%s import %s\n'%(file_name,j)
except Exception as e:
print('CRITICAL ERROR DURING GENERATION OF __init__.py')
print(e)
raise SystemExit
with open('./__init__.py','w') as initFile:
initFile.write(new_file)
os.chdir(orig_dir)
modules=['prep','run','pseudo','plot','retr','plot','aflowlib','db','scfuj','elph']
for j in modules:
try:
os.remove('./src/%s/src/__init__.py'%j)
except:
pass
for j in modules:
try:
print(('generating ./src/%s/src/__init__.py'%j))
__init__gen('./src/%s/src/'%j)
except Exception as e:
print(e)
for j in modules:
try:
os.remove('./src/%s/tests/__init__.py'%j)
except:
pass
for j in modules:
try:
print(('generating ./src/%s/tests/__init__.py'%j))
__init__gen('./src/%s/tests/'%j)
except Exception as e:
pass
try:
ACBN0=['scfuj/acbn0_support/integs.py',
'scfuj/acbn0_support/acbn0.py',
'scfuj/acbn0_support/Molecule.py',
'scfuj/acbn0_support/pyints.py',]
setup(name = "AFLOWpi",
version = version,
description = "Medium Throughput Framework for Quantum Espresso",
author = "Andrew Supka,Marco Fornari",
author_email = "supka1ar@cmich.edu",
platforms=["manylinux2014"],
url="http://aflowlib.org/src/aflowpi/",
packages = ['AFLOWpi',
'AFLOWpi.qe',
'AFLOWpi.scfuj',
'AFLOWpi.pseudo',
'AFLOWpi.run',
'AFLOWpi.retr',
'AFLOWpi.plot',
'AFLOWpi.db',
'AFLOWpi.aflowlib',
'AFLOWpi.prep',
'AFLOWpi.environ',
'AFLOWpi.elph',
],
package_dir = {'AFLOWpi' :'src',
'AFLOWpi.qe' :'src/qe',
'AFLOWpi.prep' :'src/prep/src/',
'AFLOWpi.run' :'src/run/src/',
'AFLOWpi.scfuj' :'src/scfuj/src/',
'AFLOWpi.retr' :'src/retr/src/',
'AFLOWpi.plot' :'src/plot/src/',
'AFLOWpi.pseudo' :'src/pseudo/src/',
'AFLOWpi.db' :'src/db/src/',
'AFLOWpi.elph' :'src/elph/src/',
'AFLOWpi.environ' :'src/environ/src/',
'AFLOWpi.aflowlib':'src/aflowlib/src/',
},
package_data = {
'AFLOWpi':['PAOFLOW/examples/main.py',
'scfuj/acbn0_support/*','AFLOWSYM/*'],
},
ext_modules = [Extension("cints",sources=["src/scfuj/extensions/cints.c"],include_dirs = ['src/scfuj/extensions/'],) ],
install_requires=["matplotlib","PAOFLOW==2.0.18"],
long_description = """Install Script for AFLOWpi""",)
except Exception as e:
print(e)
print('Something went wrong...exiting')
exit
def binaries_directory():
"""Return the installation directory, or None"""
# taken from stackoverflow
if '--user' in sys.argv:
paths = (site.getusersitepackages(),)
else:
py_version = '%s.%s' % (sys.version_info[0], sys.version_info[1])
paths = (s % (py_version) for s in (
sys.prefix + '/lib/python%s/dist-packages/',
sys.prefix + '/lib/python%s/site-packages/',
sys.prefix + '/local/lib/python%s/dist-packages/',
sys.prefix + '/local/lib/python%s/site-packages/',
'/Library/Python/%s/site-packages/',
))
for path in paths:
if os.path.exists(path):
return path
print('no installation path found', file=sys.stderr)
return None
try:
inst_dir=binaries_directory()
AFLOW_EXEC = os.path.join(inst_dir,'AFLOWpi','AFLOWSYM','aflow')
if not os.access(AFLOW_EXEC,3):
os.chmod(AFLOW_EXEC,733)
except Exception as e:
print(('Could not install AFLOW binary:',e))