-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
43 lines (30 loc) · 1.16 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
# coding=utf-8
import os
import subprocess
import logging
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=""):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
class CMakeBuildExt(build_ext):
def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
logging.info("extdir:", extdir)
logging.info("ext.sourcedir:", ext.sourcedir)
logging.info('self.build_temp:', self.build_temp)
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
subprocess.check_call(['cmake', ext.sourcedir, f'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}'], cwd=self.build_temp)
subprocess.check_call(['cmake', '--build', '.', '--config', 'Release', '-j16'], cwd=self.build_temp)
setup(
name='kraken',
version='0.0.2',
author='amazingyyc',
author_email='[email protected]',
zip_safe=False,
packages=['kraken', 'kraken/pytorch'],
ext_modules=[CMakeExtension('kraken')],
cmdclass={'build_ext': CMakeBuildExt},
)