setup.py 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #!/usr/bin/env python
  2. import distutils
  3. import io
  4. import json
  5. import os
  6. import setuptools
  7. import setuptools.command.build_py
  8. import distutils.command.build
  9. node_dependencies = [
  10. ( 'netron', [
  11. 'node_modules/d3/dist/d3.min.js',
  12. 'node_modules/dagre/dist/dagre.min.js',
  13. 'node_modules/handlebars/dist/handlebars.min.js',
  14. 'node_modules/marked/marked.min.js',
  15. 'node_modules/pako/dist/pako.min.js',
  16. 'node_modules/long/dist/long.js',
  17. 'node_modules/protobufjs/dist/protobuf.min.js',
  18. 'node_modules/flatbuffers/js/flatbuffers.js',
  19. 'node_modules/npm-font-open-sans/open-sans.css' ]),
  20. ( 'netron/fonts/Regular', [
  21. 'node_modules/npm-font-open-sans/fonts/Regular/OpenSans-Regular.eot',
  22. 'node_modules/npm-font-open-sans/fonts/Regular/OpenSans-Regular.svg',
  23. 'node_modules/npm-font-open-sans/fonts/Regular/OpenSans-Regular.ttf',
  24. 'node_modules/npm-font-open-sans/fonts/Regular/OpenSans-Regular.woff',
  25. 'node_modules/npm-font-open-sans/fonts/Regular/OpenSans-Regular.woff2' ]),
  26. ( 'netron/fonts/Semibold', [
  27. 'node_modules/npm-font-open-sans/fonts/Semibold/OpenSans-Semibold.eot',
  28. 'node_modules/npm-font-open-sans/fonts/Semibold/OpenSans-Semibold.svg',
  29. 'node_modules/npm-font-open-sans/fonts/Semibold/OpenSans-Semibold.ttf',
  30. 'node_modules/npm-font-open-sans/fonts/Semibold/OpenSans-Semibold.woff',
  31. 'node_modules/npm-font-open-sans/fonts/Semibold/OpenSans-Semibold.woff2' ]),
  32. ( 'netron/fonts/Bold', [
  33. 'node_modules/npm-font-open-sans/fonts/Bold/OpenSans-Bold.eot',
  34. 'node_modules/npm-font-open-sans/fonts/Bold/OpenSans-Bold.svg',
  35. 'node_modules/npm-font-open-sans/fonts/Bold/OpenSans-Bold.ttf',
  36. 'node_modules/npm-font-open-sans/fonts/Bold/OpenSans-Bold.woff',
  37. 'node_modules/npm-font-open-sans/fonts/Bold/OpenSans-Bold.woff2' ])
  38. ]
  39. class build(distutils.command.build.build):
  40. user_options = distutils.command.build.build.user_options + [ ('version', None, 'version' ) ]
  41. def initialize_options(self):
  42. distutils.command.build.build.initialize_options(self)
  43. self.version = None
  44. def finalize_options(self):
  45. distutils.command.build.build.finalize_options(self)
  46. def run(self):
  47. if self.version:
  48. build_py.version = True;
  49. else:
  50. build_py.version = False;
  51. return distutils.command.build.build.run(self)
  52. class build_py(setuptools.command.build_py.build_py):
  53. user_options = setuptools.command.build_py.build_py.user_options + [ ('version', None, 'version' ) ]
  54. def initialize_options(self):
  55. setuptools.command.build_py.build_py.initialize_options(self)
  56. self.version = None
  57. def finalize_options(self):
  58. setuptools.command.build_py.build_py.finalize_options(self)
  59. def run(self):
  60. result = setuptools.command.build_py.build_py.run(self)
  61. for target, files in node_dependencies:
  62. target = os.path.join(self.build_lib, target)
  63. if not os.path.exists(target):
  64. os.makedirs(target)
  65. for file in files:
  66. self.copy_file(file, target)
  67. return result
  68. def build_module(self, module, module_file, package):
  69. setuptools.command.build_py.build_py.build_module(self, module, module_file, package)
  70. if build_py.version and module == '__version__':
  71. package = package.split('.')
  72. outfile = self.get_module_outfile(self.build_lib, package, module)
  73. with open(outfile, 'w+') as f:
  74. f.write("__version__ = '" + package_version() + "'\n")
  75. def package_version():
  76. folder = os.path.realpath(os.path.dirname(__file__))
  77. with open(os.path.join(folder, 'package.json')) as package_file:
  78. package_manifest = json.load(package_file)
  79. return package_manifest['version']
  80. setuptools.setup(
  81. name="netron",
  82. version=package_version(),
  83. description="Viewer for neural network, deep learning and machine learning models",
  84. long_description='Netron is a viewer for neural network, deep learning and machine learning models.\n\n' +
  85. 'Netron supports **ONNX** (`.onnx`, `.pb`), **Keras** (`.h5`, `.keras`), **CoreML** (`.mlmodel`), **Caffe2** (`predict_net.pb`), **MXNet** (`.model`, `-symbol.json`), and **TensorFlow Lite** (`.tflite`). Netron has experimental support for **Caffe** (`.caffemodel`, `.prototxt`), **PyTorch** (`.pth`), **Torch** (`.t7`), **CNTK** (`.model`, `.cntk`), **PaddlePaddle** (`__model__`), **Darknet** (`.cfg`), **scikit-learn** (`.pkl`), **TensorFlow.js** (`model.json`, `.pb`) and **TensorFlow** (`.pb`, `.meta`, `.pbtxt`).',
  86. keywords=[
  87. 'onnx', 'keras', 'tensorflow', 'coreml', 'mxnet', 'caffe', 'caffe2',
  88. 'artificial intelligence', 'machine learning', 'deep learning', 'neural network',
  89. 'visualizer', 'viewer'
  90. ],
  91. license="MIT",
  92. cmdclass={
  93. 'build': build,
  94. 'build_py': build_py
  95. },
  96. package_dir={
  97. 'netron': 'src'
  98. },
  99. packages=[
  100. 'netron'
  101. ],
  102. package_data={
  103. 'netron': [
  104. 'favicon.ico', 'icon.png',
  105. 'numpy.js', 'base.js', 'zip.js', 'tar.js', 'gzip.js',
  106. 'onnx.js', 'onnx-metadata.json', 'onnx-proto.js',
  107. 'caffe.js', 'caffe-metadata.json', 'caffe-proto.js',
  108. 'caffe2.js', 'caffe2-metadata.json', 'caffe2-proto.js',
  109. 'cntk.js', 'cntk-metadata.json', 'cntk-proto.js',
  110. 'coreml.js', 'coreml-metadata.json', 'coreml-proto.js',
  111. 'darknet.js', 'darknet-metadata.json',
  112. 'keras.js', 'keras-metadata.json', 'hdf5.js',
  113. 'mxnet.js', 'mxnet-metadata.json',
  114. 'openvino.js', 'openvino-metadata.json', 'openvino-parser.js',
  115. 'paddle.js', 'paddle-metadata.json', 'paddle-proto.js',
  116. 'pytorch.js', 'pytorch-metadata.json', 'pickle.js',
  117. 'sklearn.js', 'sklearn-metadata.json',
  118. 'tf.js', 'tf-metadata.json', 'tf-proto.js',
  119. 'tflite.js', 'tflite-metadata.json', 'tflite-schema.js',
  120. 'torch.js', 'torch-metadata.json',
  121. 'view-browser.html', 'view-browser.js',
  122. 'view-grapher.css', 'view-grapher.js',
  123. 'view-sidebar.css', 'view-sidebar.js',
  124. 'view.js', 'view.css',
  125. 'server.py'
  126. ]
  127. },
  128. install_requires=[],
  129. author='Lutz Roeder',
  130. author_email='[email protected]',
  131. url='https://github.com/lutzroeder/netron',
  132. entry_points={
  133. 'console_scripts': [ 'netron = netron:main' ]
  134. },
  135. classifiers=[
  136. 'Intended Audience :: Developers',
  137. 'Intended Audience :: Education',
  138. 'Intended Audience :: Science/Research',
  139. 'Programming Language :: Python :: 2',
  140. 'Programming Language :: Python :: 2.7',
  141. 'Programming Language :: Python :: 3',
  142. 'Programming Language :: Python :: 3.6',
  143. 'Topic :: Software Development',
  144. 'Topic :: Software Development :: Libraries',
  145. 'Topic :: Software Development :: Libraries :: Python Modules',
  146. 'Topic :: Scientific/Engineering',
  147. 'Topic :: Scientific/Engineering :: Mathematics',
  148. 'Topic :: Scientific/Engineering :: Artificial Intelligence',
  149. 'Topic :: Scientific/Engineering :: Visualization'
  150. ]
  151. )