setup.py 6.1 KB

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