-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
executable file
·129 lines (113 loc) · 3.67 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
#! /usr/bin/env python3
# -*- coding:Utf8 -*-
# --------------------------------------------------------------------------------------------------------------
# All necessary import:
# --------------------------------------------------------------------------------------------------------------
import os
import sys
import glob
try:
import numpy
except ImportError:
print("Numpy is a needed dependancy.")
sys.exit(-1)
# from setuptools import find_packages
import setuptools as st
from distutils.core import setup
from distutils.command.install_data import install_data
from Cython.Distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
packages = st.find_packages()
# --------------------------------------------------------------------------------------------------------------
# Setup for the cython part:
# --------------------------------------------------------------------------------------------------------------
def scandir(dir, files=[]):
for file in os.listdir(dir):
path = os.path.join(dir, file)
if os.path.isfile(path) and path.endswith(".pyx"):
files.append(path.replace(os.path.sep, ".")[:-4])
elif os.path.isdir(path):
scandir(path, files)
return files
def makeExtension(extName, test=False, **kwargs):
"""
Create an extension for Cython with the path for the
directory in which .pyx files are presents.
"""
extPath = [extName.replace(".", os.path.sep) + ".pyx"]
cfile = extName.split(".")
dir = os.path.join(*cfile[:-1])
cfile = glob.glob(os.path.join(dir, "c*.c"))
extPath += cfile
opt_dict = dict(
include_dirs=["."], # adding the '.' to include_dirs is CRUCIAL!!
extra_compile_args=["-std=c99"],
extra_link_args=['-g'],
libraries=[],
cython_include_dirs=[
os.path.join(
os.getenv("HOME"),
'.local/lib/python' + ".".join(
[str(a) for a in sys.version_info[:2]]
) + '/site-packages/Cython/Includes'
)
]
)
for key in kwargs.keys():
if key in opt_dict:
opt_dict[key] += kwargs[key]
else:
opt_dict[key] = kwargs[key]
if test:
return extPath, opt_dict
else:
return Extension(
extName,
extPath,
**opt_dict
)
# Setup:
extNames = scandir("LISA")
extensions = []
for name in extNames:
extensions.append(
makeExtension(
name,
cython_directives={
"embedsignature": True,
}
)
)
# --------------------------------------------------------------------------------------------------------------
# Call the setup function:
# --------------------------------------------------------------------------------------------------------------
setup(
name='LISA is a Simulation Analyzer',
version='0.1a',
description='Python Module for analysis simulation.',
author='Guillaume Plum, Manuel Duarte',
cmdclass={
'install_data': install_data,
'build_ext': build_ext
},
packages=packages,
include_package_data=True,
package_data={
'LISA': [
"Data/Shaders/heightmap/*.*sh",
"Data/Shaders/sprite/*.*sh",
"Data/Shaders/halo/*.*sh",
"Data/Shaders/rippler/*.*sh",
"Data/Shaders/widget/*.*sh",
"Data/Shaders/reader/mock/*.*sh",
'Data/Shaders/*.*sh',
'Data/Textures/heightmap/*.png',
]
},
ext_modules=cythonize(
extensions,
include_path=['.']
),
)
# vim:spelllang=