-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
64 lines (50 loc) · 1.96 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
#!/usr/bin/env python
import os
import pathlib
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as setuptools_command_build_ext
class CMakeMakeExtension(Extension):
def __init__(self, name):
super().__init__(name, sources=[])
class build_ext(setuptools_command_build_ext):
def run(self):
for extension in self.extensions:
self.build_and_install_with_cmake_make(extension)
super().run()
def build_and_install_with_cmake_make(self, extension):
cwd = pathlib.Path().absolute()
build_temp = pathlib.Path(self.build_temp)
build_temp.mkdir(parents=True, exist_ok=True)
extension_dir = pathlib.Path(self.get_ext_fullpath(extension.name))
extension_dir.mkdir(parents=True, exist_ok=True)
args = [
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={}'.format(
os.path.join(str(extension_dir.parent.absolute()), 'pylspack')
), '-DPYLSPACK_ADDITIONAL_CMAKE_CXX_FLAGS={}'.format(
os.getenv('PYLSPACK_ADDITIONAL_CMAKE_CXX_FLAGS', '')
)
]
os.chdir(str(build_temp))
self.spawn(['cmake', os.path.join(str(cwd), 'src')] + args)
if not self.dry_run:
self.spawn(['make'])
os.chdir(str(cwd))
def read_readme(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name='pylspack',
version='1.0.2',
description='Python package for leverage scores computations.',
author='Sobczyk Aleksandros',
author_email='obc@zurich.ibm.com',
license='MIT',
url='https://githib.com/IBM/pylspack',
long_description=read_readme('README.md'),
long_description_content_type='text/markdown',
py_modules=['pylspack.linalg_kernels', 'pylspack.leverage_scores'],
install_requires=['scipy>=1.5.0', 'numpy>=1.19.0'],
ext_modules=[CMakeMakeExtension(name='src')],
cmdclass={
'build_ext': build_ext,
}
)