setup.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import imp
  2. import os.path
  3. from setuptools import find_packages
  4. from setuptools import setup
  5. import shlex
  6. import subprocess
  7. import sys
  8. PY3 = sys.version_info[0] == 3
  9. PY2 = sys.version_info[0] == 2
  10. assert PY3 or PY2
  11. here = os.path.abspath(os.path.dirname(__file__))
  12. version = imp.load_source(
  13. '_version', os.path.join(here, 'labelme', '_version.py')).__version__
  14. del here
  15. install_requires = [
  16. 'matplotlib',
  17. 'numpy',
  18. 'Pillow>=2.8.0',
  19. 'PyYAML',
  20. 'qtpy',
  21. ]
  22. # Find python binding for qt with priority:
  23. # PyQt5 -> PySide2 -> PyQt4,
  24. # and PyQt5 is automatically installed on Python3.
  25. QT_BINDING = None
  26. try:
  27. import PyQt5 # NOQA
  28. QT_BINDING = 'pyqt5'
  29. except ImportError:
  30. pass
  31. if QT_BINDING is None:
  32. try:
  33. import PySide2 # NOQA
  34. QT_BINDING = 'pyside2'
  35. except ImportError:
  36. pass
  37. if QT_BINDING is None:
  38. try:
  39. import PyQt4 # NOQA
  40. QT_BINDING = 'pyqt4'
  41. except ImportError:
  42. if PY2:
  43. sys.stderr.write(
  44. 'Please install PyQt5, PySide2 or PyQt4 for Python2.\n'
  45. 'Note that PyQt5 can be installed via pip for Python3.')
  46. sys.exit(1)
  47. assert PY3
  48. # PyQt5 can be installed via pip for Python3
  49. install_requires.append('PyQt5')
  50. QT_BINDING = 'pyqt5'
  51. del QT_BINDING
  52. if sys.argv[1] == 'release':
  53. commands = [
  54. 'git tag v{:s}'.format(version),
  55. 'git push origin master --tag',
  56. 'python setup.py sdist upload',
  57. ]
  58. for cmd in commands:
  59. subprocess.check_call(shlex.split(cmd))
  60. sys.exit(0)
  61. setup(
  62. name='labelme',
  63. version=version,
  64. packages=find_packages(),
  65. description='Image Polygonal Annotation with Python.',
  66. long_description=open('README.md').read(),
  67. long_description_content_type='text/markdown',
  68. author='Kentaro Wada',
  69. author_email='www.kentaro.wada@gmail.com',
  70. url='https://github.com/wkentaro/labelme',
  71. install_requires=install_requires,
  72. license='GPLv3',
  73. keywords='Image Annotation, Machine Learning',
  74. classifiers=[
  75. 'Development Status :: 5 - Production/Stable',
  76. 'Intended Audience :: Developers',
  77. 'Natural Language :: English',
  78. 'Programming Language :: Python',
  79. 'Programming Language :: Python :: 2',
  80. 'Programming Language :: Python :: 3',
  81. 'Programming Language :: Python :: Implementation :: CPython',
  82. 'Programming Language :: Python :: Implementation :: PyPy',
  83. ],
  84. package_data={'labelme': ['icons/*', 'config/*.yaml']},
  85. entry_points={
  86. 'console_scripts': [
  87. 'labelme=labelme.app:main',
  88. 'labelme_draw_json=labelme.cli.draw_json:main',
  89. 'labelme_draw_label_png=labelme.cli.draw_label_png:main',
  90. 'labelme_json_to_dataset=labelme.cli.json_to_dataset:main',
  91. 'labelme_on_docker=labelme.cli.on_docker:main',
  92. ],
  93. },
  94. )