-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py.in
More file actions
98 lines (81 loc) · 3.35 KB
/
setup.py.in
File metadata and controls
98 lines (81 loc) · 3.35 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
import os
import sys
import glob
import sysconfig
from setuptools import setup, Extension
# Get the version number of Charm
# .............................................................................
ver = open('./VERSION').read()
ret = ver.find("\n")
if ret != -1:
ver = ver[:ret]
# .............................................................................
# Get and process the user-defined compilation options
# .............................................................................
extra_compile_args = '@CFLAGS@'
include_dirs = r'@CPPFLAGS@' # r-string required for Windows paths
library_dirs = r'@LDFLAGS@' # r-string required for Windows paths
libraries = '@LIBS@'
# Transforms "string" to a list using "separator"
def to_list(string, separator):
string = string.split(separator)
string = [i.replace(' ', '') for i in string]
string = [i for i in string if i != '']
return string
# .............................................................................
# Run setup
# .............................................................................
include_dirs = to_list(include_dirs, '-I')
library_dirs = to_list(library_dirs, '-L')
if sys.platform == 'win32':
runtime_library_dirs = []
else:
runtime_library_dirs = library_dirs
# Get list of files to be compiled. It'd be great if there is some simple and
# *robust* solution of getting the list of files to be compiled from the
# autotools instead of this coding, because now we have to specify on two
# places the files that need to be compiled, separately for CHarm with
# autotools and separately for PyHarm with this "setup.py.in".
dirs_black_list = ['mpi', 'mpfr', 'gfm'] # These need a special care
ldir = os.listdir('src')
src_files = []
for i in ldir:
if os.path.isdir(os.path.join('src', i)) and i not in dirs_black_list:
src_files += glob.glob(f'src/{i}/*.c')
if @WITH_MPI@:
src_files += glob.glob('src/mpi/*c')
gfm_files = glob.glob('src/gfm/*c')
if not @WITH_MPFR@:
gfm_cap_files = glob.glob('src/gfm/gfm*_cap_*.c')
# If compiling without the MPFR support, remove all "src/gfm/gfm*_cap_*.c"
# files from "gfm_files"
gfm_files = list(set(gfm_files) - set(gfm_cap_files))
else:
gfm_files += glob.glob('src/mpfr/*c')
src_files += gfm_files
setup(name='pyharm@P@',
version=ver,
description='Python wrapper for CHarm, a C library to work with '
'spherical harmonics up to almost arbitrarily high degrees',
long_description=open('README.rst').read(),
long_description_content_type='text/x-rst',
author='Blazej Bucha',
author_email='[email protected]',
license_files = ['AUTHORS', 'COPYING'],
packages=['pyharm@P@'],
package_dir={'': 'wrap'},
url='https://github.com/blazej-bucha/charm',
install_requires=['numpy'],
ext_modules=[
Extension(
name='pyharm@[email protected]@P@',
sources=src_files,
extra_compile_args=to_list(extra_compile_args, ' '),
include_dirs=['.', './src'] + include_dirs,
library_dirs=library_dirs,
runtime_library_dirs=runtime_library_dirs,
libraries=to_list(libraries, '-l'),
),
]
)
# .............................................................................