setup.py 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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/marked/marked.min.js',
  14. 'node_modules/pako/dist/pako.min.js',
  15. 'node_modules/long/dist/long.js',
  16. 'node_modules/protobufjs/dist/protobuf.min.js',
  17. 'node_modules/protobufjs/ext/prototxt/prototxt.js',
  18. 'node_modules/flatbuffers/js/flatbuffers.js' ] )
  19. ]
  20. class build(distutils.command.build.build):
  21. user_options = distutils.command.build.build.user_options + [ ('version', None, 'version' ) ]
  22. def initialize_options(self):
  23. distutils.command.build.build.initialize_options(self)
  24. self.version = None
  25. def finalize_options(self):
  26. distutils.command.build.build.finalize_options(self)
  27. def run(self):
  28. build_py.version = bool(self.version)
  29. return distutils.command.build.build.run(self)
  30. class build_py(setuptools.command.build_py.build_py):
  31. user_options = setuptools.command.build_py.build_py.user_options + [ ('version', None, 'version' ) ]
  32. def initialize_options(self):
  33. setuptools.command.build_py.build_py.initialize_options(self)
  34. self.version = None
  35. def finalize_options(self):
  36. setuptools.command.build_py.build_py.finalize_options(self)
  37. def run(self):
  38. setuptools.command.build_py.build_py.run(self)
  39. for target, files in node_dependencies:
  40. target = os.path.join(self.build_lib, target)
  41. if not os.path.exists(target):
  42. os.makedirs(target)
  43. for file in files:
  44. self.copy_file(file, target)
  45. def build_module(self, module, module_file, package):
  46. setuptools.command.build_py.build_py.build_module(self, module, module_file, package)
  47. if build_py.version and module == '__version__':
  48. package = package.split('.')
  49. outfile = self.get_module_outfile(self.build_lib, package, module)
  50. with open(outfile, 'w+') as f:
  51. f.write("__version__ = '" + package_version() + "'\n")
  52. def package_version():
  53. folder = os.path.realpath(os.path.dirname(__file__))
  54. with open(os.path.join(folder, 'package.json')) as package_file:
  55. package_manifest = json.load(package_file)
  56. return package_manifest['version']
  57. setuptools.setup(
  58. name="netron",
  59. version=package_version(),
  60. description="Viewer for neural network, deep learning and machine learning models",
  61. long_description='Netron is a viewer for neural network, deep learning and machine learning models.\n\n' +
  62. 'Netron supports **ONNX** (`.onnx`, `.pb`), **Keras** (`.h5`, `.keras`), **Core ML** (`.mlmodel`), **Caffe** (`.caffemodel`, `.prototxt`), **Caffe2** (`predict_net.pb`), **Darknet** (`.cfg`), **MXNet** (`.model`, `-symbol.json`), ncnn (`.param`) and **TensorFlow Lite** (`.tflite`). Netron has experimental support for **TorchScript** (`.pt`, `.pth`), **PyTorch** (`.pt`, `.pth`), **Torch** (`.t7`), **ArmNN** (`.armnn`), **BigDL** (`.bigdl`, `.model`), **Chainer** (`.npz`, `.h5`), **CNTK** (`.model`, `.cntk`), **Deeplearning4j** (`.zip`), **PaddlePaddle** (`__model__`), **MediaPipe** (`.pbtxt`), **ML.NET** (`.zip`), MNN (`.mnn`), **OpenVINO** (`.xml`), **scikit-learn** (`.pkl`), **Tengine** (`.tmfile`), **TensorFlow.js** (`model.json`, `.pb`) and **TensorFlow** (`.pb`, `.meta`, `.pbtxt`, `.ckpt`, `.index`).',
  63. keywords=[
  64. 'onnx', 'keras', 'tensorflow', 'tflite', 'coreml', 'mxnet', 'caffe', 'caffe2', 'torchscript', 'pytorch', 'ncnn', 'mnn' 'openvino', 'darknet', 'paddlepaddle', 'chainer',
  65. 'artificial intelligence', 'machine learning', 'deep learning', 'neural network',
  66. 'visualizer', 'viewer'
  67. ],
  68. license="MIT",
  69. cmdclass={
  70. 'build': build,
  71. 'build_py': build_py
  72. },
  73. package_dir={
  74. 'netron': 'src'
  75. },
  76. packages=[
  77. 'netron'
  78. ],
  79. package_data={
  80. 'netron': [
  81. 'favicon.ico', 'icon.png',
  82. 'base.js',
  83. 'numpy.js', 'pickle.js', 'hdf5.js', 'bson.js',
  84. 'zip.js', 'tar.js', 'gzip.js',
  85. 'armnn.js', 'armnn-metadata.json', 'armnn-schema.js',
  86. 'bigdl.js', 'bigdl-metadata.json', 'bigdl-proto.js',
  87. 'caffe.js', 'caffe-metadata.json', 'caffe-proto.js',
  88. 'caffe2.js', 'caffe2-metadata.json', 'caffe2-proto.js',
  89. 'chainer.js',
  90. 'cntk.js', 'cntk-metadata.json', 'cntk-proto.js',
  91. 'coreml.js', 'coreml-metadata.json', 'coreml-proto.js',
  92. 'darknet.js', 'darknet-metadata.json',
  93. 'dl4j.js', 'dl4j-metadata.json',
  94. 'flux.js', 'flux-metadata.json',
  95. 'keras.js', 'keras-metadata.json',
  96. 'mediapipe.js',
  97. 'mlnet.js', 'mlnet-metadata.json',
  98. 'mnn.js', 'mnn-metadata.json', 'mnn-schema.js',
  99. 'mxnet.js', 'mxnet-metadata.json',
  100. 'ncnn.js', 'ncnn-metadata.json',
  101. 'onnx.js', 'onnx-metadata.json', 'onnx-proto.js',
  102. 'openvino.js', 'openvino-metadata.json', 'openvino-parser.js',
  103. 'paddle.js', 'paddle-metadata.json', 'paddle-proto.js',
  104. 'pytorch.js', 'pytorch-metadata.json', 'python.js',
  105. 'sklearn.js', 'sklearn-metadata.json',
  106. 'tengine.js', 'tengine-metadata.json',
  107. 'tf.js', 'tf-metadata.json', 'tf-proto.js',
  108. 'tflite.js', 'tflite-metadata.json', 'tflite-schema.js',
  109. 'torch.js', 'torch-metadata.json',
  110. 'index.html', 'index.js',
  111. 'view-grapher.css', 'view-grapher.js',
  112. 'view-sidebar.css', 'view-sidebar.js',
  113. 'view.js',
  114. 'server.py'
  115. ]
  116. },
  117. install_requires=[],
  118. author='Lutz Roeder',
  119. author_email='[email protected]',
  120. url='https://github.com/lutzroeder/netron',
  121. entry_points={
  122. 'console_scripts': [ 'netron = netron:main' ]
  123. },
  124. classifiers=[
  125. 'Intended Audience :: Developers',
  126. 'Intended Audience :: Education',
  127. 'Intended Audience :: Science/Research',
  128. 'Programming Language :: Python :: 2',
  129. 'Programming Language :: Python :: 2.7',
  130. 'Programming Language :: Python :: 3',
  131. 'Programming Language :: Python :: 3.6',
  132. 'Topic :: Software Development',
  133. 'Topic :: Software Development :: Libraries',
  134. 'Topic :: Software Development :: Libraries :: Python Modules',
  135. 'Topic :: Scientific/Engineering',
  136. 'Topic :: Scientific/Engineering :: Mathematics',
  137. 'Topic :: Scientific/Engineering :: Artificial Intelligence',
  138. 'Topic :: Scientific/Engineering :: Visualization'
  139. ]
  140. )