-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·136 lines (121 loc) · 5.19 KB
/
setup.py
File metadata and controls
executable file
·136 lines (121 loc) · 5.19 KB
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
#!/usr/bin/python
import numpy as np
from _version import __version__
import re, os, sys, subprocess
#import cython_gsl
import numpy as np
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
VERSIONFILE="_version.py"
verstrline = open(VERSIONFILE, "rt").read()
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
if mo:
verstr = mo.group(1)
else:
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
args = sys.argv[1:]
# Make a `cleanall` rule to get rid of intermediate and library files
if "cleanall" in args:
print "Deleting cython files..."
# Just in case the build directory was created by accident,
# note that shell=True should be OK here because the command is constant.
subprocess.Popen("rm -rf ./build", shell=True, executable="/bin/bash")
subprocess.Popen("find ./ -name *.c | xargs rm", shell=True)
subprocess.Popen("find ./ -name *.so | xargs rm", shell=True)
# Now do a normal clean
sys.argv[1] = "clean"
exit(1)
# We want to always use build_ext --inplace
if args.count("build_ext") > 0 and args.count("--inplace") == 0:
sys.argv.insert(sys.argv.index("build_ext") + 1, "--inplace")
# Only build for 64-bit target
# os.environ['ARCHFLAGS'] = "-arch x86_64"
# Set up extension and build
cy_ext_options = {"compiler_directives": {"profile": True}, "annotate": True}
cy_ext = [
# Extension("beams.bunch",
# ["beams/bunch.pyx"],
# include_dirs=[np.get_include()],
# #extra_compile_args=["-g"],
# #extra_link_args=["-g"],
# libraries=["m"],
# library_dirs=[],
# ),
Extension("solvers.grid_functions",
["solvers/grid_functions.pyx"],
include_dirs=[np.get_include()], library_dirs=[], libraries=["m"],
extra_compile_args=["-fopenmp"],
extra_link_args=["-fopenmp"],
),
Extension("cobra_functions.stats",
["cobra_functions/stats.pyx"],
include_dirs=[np.get_include()], library_dirs=[], libraries=["m"],
extra_compile_args=["-fopenmp"],
extra_link_args=["-fopenmp"],
#extra_compile_args=["-g"],
#extra_link_args=["-g"],
),
#Extension("cobra_functions.random",
#["cobra_functions/random.pyx"],
#include_dirs=[np.get_include(), cython_gsl.get_cython_include_dir()],
##extra_compile_args=["-g"],
##extra_link_args=["-g"],
#library_dirs=[], libraries=["gsl", "gslcblas"],
#),
Extension("solvers.compute_potential_fgreenm2m",
["solvers/compute_potential_fgreenm2m.pyx"],
include_dirs=[np.get_include()], library_dirs=[], libraries=["m"],
#extra_compile_args=["-g"],
#extra_link_args=["-g"],
),
# Extension("cobra_functions.interp1d",
# ["cobra_functions/interp1d.pyx"],
# include_dirs=[np.get_include()], library_dirs=[], libraries=["m"],
# #extra_compile_args=["-g"],
# #extra_link_args=["-g"],
# ),
Extension("trackers.transverse_tracking_cython",
["trackers/transverse_tracking_cython.pyx"],
include_dirs=[np.get_include()], library_dirs=[], libraries=["m"],
extra_compile_args=["-fopenmp"],
extra_link_args=["-fopenmp"],
#extra_compile_args=["-g"],
#extra_link_args=["-g"],
),
Extension("trackers.detuners_cython",
["trackers/detuners_cython.pyx"],
include_dirs=[np.get_include()], library_dirs=[], libraries=["m"],
extra_compile_args=["-fopenmp"],
extra_link_args=["-fopenmp"],
#extra_compile_args=["-g"],
#extra_link_args=["-g"],
),
Extension("rfq.rfq",
["rfq/rfq.pyx"],
include_dirs=[np.get_include()], library_dirs=[], libraries=["m"],
extra_compile_args=["-fopenmp"],
extra_link_args=["-fopenmp"],
#extra_compile_args=["-g"],
#extra_link_args=["-g"],
),
Extension("aperture.aperture",
["aperture/aperture.pyx"],
include_dirs=[np.get_include()], library_dirs=[], libraries=["m"],
#extra_compile_args=["-fopenmp"],
#extra_link_args=["-fopenmp"],
#extra_compile_args=["-g"],
#extra_link_args=["-g"],
)
]
setup(
name='PyHEADTAIL',
version=verstr,
description='CERN macroparticle tracking code for collective effects in circular accelerators.',
url='http://github.com/like2000/PyHEADTAIL',
packages=['PyHEADTAIL'],
cmdclass={'build_ext': build_ext},
ext_modules=cythonize(cy_ext, **cy_ext_options),
)