forked from PyCOMPLETE/PyHEADTAIL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·112 lines (92 loc) · 3.94 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
#!/usr/bin/env python
# thanks to Nick Foti for his cython skeleton, cf.
# http://nfoti.github.io/a-creative-blog-name/posts/2013/02/07/cleaning-cython-build-files/
import numpy as np
from PyHEADTAIL._version import __version__
import os, sys, subprocess
from setuptools import setup, Extension, find_packages
from Cython.Build import cythonize
from Cython.Distutils import build_ext
import platform
if platform.system() is 'Darwin':
print ("Info: since you are running Mac OS, you "
"may have to install with the following line:\n\n"
"$ CC=gcc-4.9 ./install\n"
"(or any equivalent version of gcc)")
input('Hit any key to continue...')
args = sys.argv[1:]
# Make a `cleanall` rule to get rid of intermediate and library files
if "cleanall" in args:
print ("Deleting cython and fortran compilation 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 -f", shell=True)
subprocess.Popen("find ./ -name *.so | xargs rm -f", shell=True)
subprocess.Popen("find ./ -name *.html | xargs rm -f", shell=True)
# Now do a normal clean
sys.argv = [sys.argv[0], 'clean']
# 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")
with open('README.rst', 'rb') as f:
long_description = f.read().decode('utf-8')
# Only build for 64-bit target
# os.environ['ARCHFLAGS'] = "-arch x86_64"
# Set up extension and build
cy_ext_options = {
"compiler_directives": {"profile": False, # SLOW!!!
"embedsignature": True,
"linetrace": False,
"language_level": sys.version_info[0],
},
"annotate": True,
}
cy_ext = [
Extension("PyHEADTAIL.cobra_functions.stats",
["PyHEADTAIL/cobra_functions/stats.pyx"],
include_dirs=[np.get_include()],
library_dirs=[], libraries=["m"],
extra_compile_args=["-fopenmp"], extra_link_args=["-fopenmp"]),
Extension("PyHEADTAIL.aperture.aperture_cython",
["PyHEADTAIL/aperture/aperture_cython.pyx"],
include_dirs=[np.get_include()],
library_dirs=[], libraries=["m"]),
Extension("PyHEADTAIL.cobra_functions.c_sin_cos",
["PyHEADTAIL/cobra_functions/c_sin_cos.pyx"],
include_dirs=[np.get_include()],
library_dirs=[], libraries=["m"],
extra_compile_args=["-fopenmp"], extra_link_args=["-fopenmp"]),
Extension("PyHEADTAIL.cobra_functions.interp_sin_cos",
["PyHEADTAIL/cobra_functions/interp_sin_cos.pyx"],
include_dirs=[np.get_include()],
library_dirs=[], libraries=["m"],
extra_compile_args=["-fopenmp"], extra_link_args=["-fopenmp"])
]
setup(
name='PyHEADTAIL',
version=__version__,
description='CERN PyHEADTAIL numerical n-body simulation code '
'for simulating macro-particle beam dynamics with collective effects.',
url='https://github.com/PyCOMPLETE/PyHEADTAIL',
author='Kevin Li',
author_email='[email protected]',
maintainer='Adrian Oeftiger',
maintainer_email='[email protected]',
packages=find_packages(),
long_description=long_description,
cmdclass={'build_ext': build_ext},
ext_modules=cythonize(cy_ext, **cy_ext_options),
include_package_data=True, # install files matched by MANIFEST.in
setup_requires=[
'numpy',
'scipy',
'h5py',
'cython',
]
)
# from numpy.distutils.core import setup, Extension
# setup(
# ext_modules = [Extension('PyHEADTAIL.general.errfff',
# ['PyHEADTAIL/general/errfff.f90'])],
# )