setup.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/usr/bin/python
  2. import distutils
  3. import os
  4. import setuptools
  5. import setuptools.command
  6. import setuptools.command.build_py
  7. import json
  8. TOP_DIR = os.path.realpath(os.path.dirname(__file__))
  9. with open(os.path.join(TOP_DIR, 'package.json')) as package_file:
  10. package_manifest = json.load(package_file)
  11. package_version = package_manifest['version']
  12. packages = [ 'netron' ]
  13. package_data={
  14. 'netron': [
  15. 'netron',
  16. 'netron.py',
  17. 'logo.svg',
  18. 'onnx_ml_pb2.py',
  19. 'onnx.js',
  20. 'onnx-operator.json',
  21. 'view-browser.js',
  22. 'tf.js',
  23. 'tf-operator.pb',
  24. 'tf-model.js',
  25. 'tflite.js',
  26. 'tflite-operator.json',
  27. 'tflite-model.js',
  28. 'hdf5.js',
  29. 'keras-operator.json',
  30. 'keras-model.js',
  31. 'favicon.ico',
  32. 'view-browser.html',
  33. 'onnx-model.js',
  34. 'view-render.css',
  35. 'view-render.js',
  36. 'view-template.js',
  37. 'view.css',
  38. 'view.js',
  39. ]
  40. }
  41. install_requires = [ 'protobuf' ]
  42. scripts = [ 'src/netron' ]
  43. custom_files = [
  44. ( 'netron', [
  45. 'node_modules/d3/build/d3.min.js',
  46. 'node_modules/dagre/dist/dagre.min.js',
  47. 'node_modules/handlebars/dist/handlebars.min.js',
  48. 'node_modules/marked/marked.min.js',
  49. 'node_modules/protobufjs/dist/protobuf.min.js',
  50. 'node_modules/flatbuffers/js/flatbuffers.js',
  51. 'node_modules/npm-font-open-sans/open-sans.css' ]),
  52. ( 'netron/fonts/Regular', [
  53. 'node_modules/npm-font-open-sans/fonts/Regular/OpenSans-Regular.eot',
  54. 'node_modules/npm-font-open-sans/fonts/Regular/OpenSans-Regular.svg',
  55. 'node_modules/npm-font-open-sans/fonts/Regular/OpenSans-Regular.ttf',
  56. 'node_modules/npm-font-open-sans/fonts/Regular/OpenSans-Regular.woff',
  57. 'node_modules/npm-font-open-sans/fonts/Regular/OpenSans-Regular.woff2' ]),
  58. ( 'netron/fonts/Semibold', [
  59. 'node_modules/npm-font-open-sans/fonts/Semibold/OpenSans-Semibold.eot',
  60. 'node_modules/npm-font-open-sans/fonts/Semibold/OpenSans-Semibold.svg',
  61. 'node_modules/npm-font-open-sans/fonts/Semibold/OpenSans-Semibold.ttf',
  62. 'node_modules/npm-font-open-sans/fonts/Semibold/OpenSans-Semibold.woff',
  63. 'node_modules/npm-font-open-sans/fonts/Semibold/OpenSans-Semibold.woff2' ]),
  64. ( 'netron/fonts/Bold', [
  65. 'node_modules/npm-font-open-sans/fonts/Bold/OpenSans-Bold.eot',
  66. 'node_modules/npm-font-open-sans/fonts/Bold/OpenSans-Bold.svg',
  67. 'node_modules/npm-font-open-sans/fonts/Bold/OpenSans-Bold.ttf',
  68. 'node_modules/npm-font-open-sans/fonts/Bold/OpenSans-Bold.woff',
  69. 'node_modules/npm-font-open-sans/fonts/Bold/OpenSans-Bold.woff2' ])
  70. ]
  71. class build_py(setuptools.command.build_py.build_py):
  72. def run(self):
  73. result = setuptools.command.build_py.build_py.run(self)
  74. for target, files in custom_files:
  75. target = os.path.join(self.build_lib, target)
  76. if not os.path.exists(target):
  77. os.makedirs(target)
  78. for file in files:
  79. self.copy_file(file, target)
  80. return result
  81. def get_outputs(self, include_bytecode=1):
  82. result = setuptools.command.build_py.build_py.get_outputs(self, include_bytecode)
  83. print("## get_outputs ##")
  84. return result
  85. setuptools.setup(
  86. name="netron",
  87. version=package_version,
  88. description="Viewer for neural network models",
  89. license="MIT",
  90. cmdclass={ 'build_py': build_py },
  91. package_dir={ 'netron': 'src' },
  92. packages=packages,
  93. package_data=package_data,
  94. install_requires=install_requires,
  95. author='Lutz Roeder',
  96. author_email='[email protected]',
  97. url='https://github.com/lutzroeder/Netron',
  98. scripts=scripts,
  99. classifiers=[
  100. 'Intended Audience :: Developers',
  101. 'Intended Audience :: Science/Research',
  102. 'Topic :: Software Development',
  103. 'Topic :: Scientific/Engineering :: Artificial Intelligence'
  104. ]
  105. )