forked from abinit/abipy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·213 lines (175 loc) · 6.1 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
#!/usr/bin/env python
"""Setup script for abipy."""
from __future__ import print_function
import sys
import os
import shutil
import numpy as np
from glob import glob
from setuptools import find_packages, setup, Extension
# This check is also made in abipy/__init__, don't forget to update both when
# changing Python version requirements.
if sys.version[0:3] < '2.7':
sys.stderr.write("abipy requires Python version 2.7 or above. Exiting.")
sys.exit(1)
#cmdclass = {}
ext_modules = []
#-------------------------------------------------------------------------------
# Useful globals and utility functions
#-------------------------------------------------------------------------------
# A little utility we'll need below, since glob() does NOT allow you to do exclusion on multiple endings!
def file_doesnt_end_with(test, endings):
"""
Returns true if test is a file and its name does NOT end with any
of the strings listed in endings.
"""
if not os.path.isfile(test):
return False
for e in endings:
if test.endswith(e):
return False
return True
#---------------------------------------------------------------------------
# Basic project information
#---------------------------------------------------------------------------
# release.py contains version, authors, license, url, keywords, etc.
release_file = os.path.join('abipy','core','release.py')
with open(release_file) as f:
code = compile(f.read(), release_file, 'exec')
exec(code)
#---------------------------------------------------------------------------
# Find packages
#---------------------------------------------------------------------------
#
#def find_packages():
# """
# Find all of abipy's packages.
# """
# return find_packages(exclude=())
#---------------------------------------------------------------------------
# Find package data
#---------------------------------------------------------------------------
def find_package_data():
"""Find abipy's package_data."""
#top = os.path.join("abipy", "data", "refs")
#ref_files = {}
#for root, dirs, files in os.walk(top):
# root = root.replace("/", ".")
# ref_files[root] = [os.path.join(root, f) for f in files]
#print(ref_files)
# This is not enough for these things to appear in an sdist.
# We need to muck with the MANIFEST to get this to work
package_data = {
'abipy.data': [
"cifs/*.cif",
"pseudos/*",
"hgh_pseudos/*",
"runs/*",
"managers/*",
"refs/*.nc",
"refs/*.log",
"refs/*.abo",
"variables/*",
],
'abipy.data.refs' : [
"al_eph/*",
"al_g0w0_spfunc/*",
"alas_nl_dfpt/*",
"alas_phonons/*",
#"diamond_sigeph/*",
"gaas_optic/*",
"mgb2_fatbands/*",
"ni_ebands/*",
"si_bse/*",
"si_bse_kpoints/*",
"si_ebands/*",
"si_g0w0/*",
"sio2_screening/*",
"znse_phonons/*",
],
'abipy.htc': ["*.json"],
'abipy.gui.awx' : ['images/*'],
}
return package_data
def find_exclude_package_data():
package_data = {
'abipy.data': ["managers", 'benchmarks', 'runs/flow_*', 'runs/gspert'],
}
return package_data
#---------------------------------------------------------------------------
# Find scripts
#---------------------------------------------------------------------------
def find_scripts():
"""Find abipy scripts."""
scripts = []
# All python files in abipy/scripts
pyfiles = glob(os.path.join('abipy', 'scripts', "*.py"))
scripts.extend(pyfiles)
return scripts
def get_long_desc():
with open("README.rst") as f:
return f.read()
return long_desc
#-----------------------------------------------------------------------------
# Function definitions
#-----------------------------------------------------------------------------
def cleanup():
"""Clean up the junk left around by the build process."""
if "develop" not in sys.argv:
try:
shutil.rmtree('abipy.egg-info')
except (IOError, OSError):
try:
os.unlink('abipy.egg-info')
except:
pass
# List of external packages we rely on.
# Note setup install will download them from Pypi if they are not available.
with open("requirements.txt", "rt") as fh:
install_requires = [s.strip() for s in fh]
with_wxpython = False
if with_wxpython:
install_requires += [
"wxmplot",
"wxpython",
]
#print("install_requires\n", install_requires)
#---------------------------------------------------------------------------
# Find all the packages, package data, and data_files
#---------------------------------------------------------------------------
# Create a dict with the basic information
# This dict is eventually passed to setup after additional keys are added.
setup_args = dict(
name=name,
version=version,
description=description,
long_description=long_description,
author=author,
author_email=author_email,
maintainer=maintainer,
maintainer_email=maintainer_email,
url=url,
license=license,
platforms=platforms,
keywords=keywords,
classifiers=classifiers,
install_requires=install_requires,
packages=find_packages(exclude=()),
package_data=find_package_data(),
exclude_package_data=find_exclude_package_data(),
scripts=find_scripts(),
download_url=download_url,
ext_modules=ext_modules,
)
if __name__ == "__main__":
setup(**setup_args)
print("""
Please read the following if you are about to use abipy for the first time:
[1]
abipy needs to know about the cluster/computer you are running on. This information
is provided via the manager.yml and scheduler.yml files. These files must be located
in ~/.abinit/abipy or in the working directory in which you execute the flow.
Examples are provided in abipy/data/managers
Have fun!
""")
cleanup()