-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
68 lines (54 loc) · 1.86 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
import os
import pathlib
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext as build_ext_orig
__version__ = "0.2.4"
class CMakeExtension(Extension):
def __init__(self, name):
# don't invoke the original build_ext for this special extension
super().__init__(name, sources=[])
class build_ext(build_ext_orig):
def run(self):
for ext in self.extensions:
self.build_cmake(ext)
#super().run()
def build_cmake(self, ext):
cwd = pathlib.Path().absolute()
build_temp = pathlib.Path(self.build_temp)
build_temp.mkdir(parents=True, exist_ok=True)
extdir = pathlib.Path(self.get_ext_fullpath(ext.name))
config = 'Release ' + '--j4'
cmake_args = [
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + str(extdir.parent.absolute()),
'-DCMAKE_BUILD_TYPE=' + config
]
build_args = [
'--config', config
]
os.chdir(str(build_temp))
self.spawn(['cmake', str(cwd)] + cmake_args)
if not self.dry_run:
if os.name != "nt":
self.spawn(['cmake', '--build', '.'] + build_args)
else:
self.spawn(['cmake', '--build', '.'])
os.chdir(str(cwd))
setup(
name='MockSZ',
license="MIT",
version=__version__,
author="Arend Moerman",
install_requires = ["numpy", "wheel", "cmake"],
package_dir = {'': 'src'},
packages=['MockSZ'],
ext_modules=[CMakeExtension(os.path.join("MockSZ", "libs"))],
cmdclass={'build_ext': build_ext},
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: C",
"Programming Language :: C++",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.8'
)