-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathsetup.py
More file actions
53 lines (39 loc) · 1.29 KB
/
setup.py
File metadata and controls
53 lines (39 loc) · 1.29 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
#! /usr/bin/env python
'''
Brian2 setup script
'''
# isort:skip_file
import os
import numpy
from setuptools import setup, Extension
from typing import List
# A Helper function to require cython extension
def require_cython_extension(module_path, module_name,extra_include_dirs=None):
"""
Create a cythonized Extension object from a .pyx source.
"""
# File paths
base_path = os.path.join(*module_path)
pyx_file = os.path.join(base_path, f"{module_name}.pyx")
# Module name for setuptools
full_module_name = ".".join(module_path + [module_name])
include_dirs = [numpy.get_include()]
if extra_include_dirs:
include_dirs.extend(extra_include_dirs)
ext = Extension(full_module_name, [pyx_file],include_dirs=include_dirs)
return ext
# Collect Extensions
extensions : List[Extension]=[]
# Now Cython is required and no python fallback is possible
spike_queue_ext = require_cython_extension(
module_path=["brian2", "synapses"],
module_name="cythonspikequeue",
)
extensions.append(spike_queue_ext)
dynamic_array_ext = require_cython_extension(
module_path=["brian2", "memory"],
module_name="cythondynamicarray",
extra_include_dirs=["brian2/devices/cpp_standalone/brianlib"]
)
extensions.append(dynamic_array_ext)
setup(ext_modules=extensions)