-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
50 lines (39 loc) · 1.61 KB
/
setup.py
File metadata and controls
50 lines (39 loc) · 1.61 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
48
49
import os
import sys
import distutils.ccompiler
import subprocess
import distutils.command.install
from setuptools import setup
import setuptools
class CustomInstall(setuptools.Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print('file', __file__)
print('dirname', os.path.dirname(os.path.abspath(__file__)))
print('listdir', os.listdir(os.path.dirname(os.path.abspath(__file__))))
lib_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'QuickDataFlow/build')
if os.path.exists(lib_path):
print(f'\033[91m path:{lib_path} is exist \033[0m')
else:
os.mkdir(lib_path)
print('cmake config')
cmake_config = 'cmake -DBUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=RELEASE -S ../.. -B .'
ret = subprocess.run(cmake_config, stderr=subprocess.STDOUT, shell=True, cwd=lib_path)
print('cmake build')
cmake_build = 'cmake --build . --clean-first --target QuickDataFlow'
ret = subprocess.run(cmake_build, stderr=subprocess.STDOUT, shell=True, cwd=lib_path)
class install(distutils.command.install.install):
_sub_command = ('CustomInstall', None,)
_sub_commands = distutils.command.install.install.sub_commands
sub_commands = [_sub_command] + _sub_commands
if __name__ == '__main__':
setup(
cmdclass={'CustomInstall': CustomInstall,
'install': install},
# package_data={"QuickDataFlow": ["_precompiled_extension.pyd"]},
has_ext_modules=lambda: True
)