forked from cherab/mastu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
59 lines (47 loc) · 1.56 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
from setuptools import setup, find_packages, Extension
from Cython.Build import cythonize
import sys
import numpy
import os
import os.path as path
import multiprocessing
def add_extensions(setup_path, folder, extensions):
"""
Adds .pyx files in the specified folder to the list of extensions.
"""
source_path = path.join(setup_path, folder)
for root, dirs, files in os.walk(source_path):
for file in files:
if path.splitext(file)[1] == ".pyx":
pyx_file = path.relpath(path.join(root, file), setup_path)
module = path.splitext(pyx_file)[0].replace("/", ".")
extensions.append(Extension(module, [pyx_file], include_dirs=compilation_includes),)
threads = multiprocessing.cpu_count()
force = False
profile = False
if "--force" in sys.argv:
force = True
del sys.argv[sys.argv.index("--force")]
if "--profile" in sys.argv:
profile = True
del sys.argv[sys.argv.index("--profile")]
compilation_includes = [".", numpy.get_include()]
setup_path = path.dirname(path.abspath(__file__))
source_folders = ['cherab', 'demos']
# build extension list
extensions = []
for folder in source_folders:
add_extensions(setup_path, folder, extensions)
if profile:
directives = {"profile": True}
else:
directives = {}
setup(
name="cherab-mastu",
version="1.0.0",
license="EUPL 1.1",
namespace_packages=['cherab'],
packages=find_packages(),
include_package_data=True,
ext_modules=cythonize(extensions, nthreads=threads, force=force, compiler_directives=directives)
)