setup.py 2.9 KB

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