-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.py
More file actions
46 lines (40 loc) · 1.27 KB
/
Copy pathsetup.py
File metadata and controls
46 lines (40 loc) · 1.27 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
import typing as tp
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
import site, os
from pathlib import Path
AK_VERSION = Path('VERSION').read_text(encoding='utf-8').strip()
def get_ext_dir(*components: tp.Iterable[str]) -> tp.Sequence[str]:
dirs = []
# Check user site-packages
user_site = site.getusersitepackages()
if user_site:
fp = os.path.join(user_site, *components)
if os.path.exists(fp):
dirs.append(fp)
# Check system site-packages
for sp in site.getsitepackages():
fp = os.path.join(sp, *components)
if os.path.exists(fp):
dirs.append(fp)
return dirs
ext_modules = [
Extension(
name='arraykit._arraykit',
sources=[
'src/_arraykit.c',
'src/array_go.c',
'src/array_to_tuple.c',
'src/block_index.c',
'src/delimited_to_arrays.c',
'src/methods.c',
'src/tri_map.c',
'src/auto_map.c',
],
include_dirs=get_ext_dir('numpy', '_core', 'include') + ['src'],
library_dirs=get_ext_dir('numpy', '_core', 'lib'),
define_macros=[('AK_VERSION', AK_VERSION)],
libraries=['npymath'],
)
]
setup(ext_modules=ext_modules)