-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·47 lines (38 loc) · 1.43 KB
/
setup.py
File metadata and controls
executable file
·47 lines (38 loc) · 1.43 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
#!/usr/bin/env python
import os
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
class build_ext(build_ext):
def get_export_symbols(self, ext):
if isinstance(ext, CTypes):
return ext.export_symbols
return super().get_export_symbols(ext)
def get_ext_filename(self, ext_name):
if isinstance(self.ext_map[ext_name], CTypes):
# Ensure that the extension ends in ".so"
# Modified version of parent method
from setuptools.command.build_ext import get_config_var
ext_suffix = get_config_var('EXT_SUFFIX')
expanded_suffix = ext_suffix.split('.')
expanded_suffix[-1] = "so"
ext_suffix = ".".join(expanded_suffix)
ext_path = ext_name.split('.')
return os.path.join(*ext_path) + ext_suffix
return super().get_ext_filename(ext_name)
class CTypes(Extension):
pass
setup_kwargs = {
"use_scm_version": {"write_to": os.path.join("src", "mcalf", "_version.py")},
"setup_requires": ["setuptools_scm"],
}
if not os.getenv("MCALF_NO_EXTENSIONS"):
is_nt = '_nt' if os.name == 'nt' else ''
setup_kwargs["ext_modules"] = [
CTypes(
"mcalf.profiles.ext_voigtlib",
["cextern/voigt{}.c".format(is_nt)],
py_limited_api=True
),
]
setup_kwargs["cmdclass"] = {'build_ext': build_ext}
setup(**setup_kwargs)