setup.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # Copyright (c) <2015-Present> Tzutalin
  2. # Copyright (C) 2013 MIT, Computer Science and Artificial Intelligence Laboratory. Bryan Russell, Antonio Torralba,
  3. # William T. Freeman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
  4. # associated documentation files (the "Software"), to deal in the Software without restriction, including without
  5. # limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
  6. # Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  7. # The above copyright notice and this permission notice shall be included in all copies or substantial portions of
  8. # the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
  9. # NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
  10. # SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  11. # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12. # THE SOFTWARE.
  13. #!/usr/bin/env python
  14. # -*- coding: utf-8 -*-
  15. from setuptools import setup, find_packages, Command
  16. from sys import platform as _platform
  17. from shutil import rmtree
  18. import sys
  19. import os
  20. here = os.path.abspath(os.path.dirname(__file__))
  21. NAME = 'labelImg'
  22. REQUIRES_PYTHON = '>=3.0.0'
  23. REQUIRED_DEP = ['pyqt5', 'lxml']
  24. about = {}
  25. with open(os.path.join(here, 'libs', '__init__.py')) as f:
  26. exec(f.read(), about)
  27. with open('README.rst') as readme_file:
  28. readme = readme_file.read()
  29. with open('HISTORY.rst') as history_file:
  30. history = history_file.read()
  31. # OS specific settings
  32. SET_REQUIRES = []
  33. if _platform == "linux" or _platform == "linux2":
  34. # linux
  35. print('linux')
  36. elif _platform == "darwin":
  37. # MAC OS X
  38. SET_REQUIRES.append('py2app')
  39. required_packages = find_packages()
  40. required_packages.append('labelImg')
  41. APP = [NAME + '.py']
  42. OPTIONS = {
  43. 'argv_emulation': True,
  44. 'iconfile': 'resources/icons/app.icns'
  45. }
  46. class UploadCommand(Command):
  47. """Support setup.py upload."""
  48. description=readme + '\n\n' + history,
  49. user_options = []
  50. @staticmethod
  51. def status(s):
  52. """Prints things in bold."""
  53. print('\033[1m{0}\033[0m'.format(s))
  54. def initialize_options(self):
  55. pass
  56. def finalize_options(self):
  57. pass
  58. def run(self):
  59. try:
  60. self.status('Removing previous builds…')
  61. rmtree(os.path.join(here, 'dist'))
  62. except OSError:
  63. self.status('Fail to remove previous builds..')
  64. pass
  65. self.status('Building Source and Wheel (universal) distribution…')
  66. os.system(
  67. '{0} setup.py sdist bdist_wheel --universal'.format(sys.executable))
  68. self.status('Uploading the package to PyPI via Twine…')
  69. os.system('twine upload dist/*')
  70. self.status('Pushing git tags…')
  71. os.system('git tag -d v{0}'.format(about['__version__']))
  72. os.system('git tag v{0}'.format(about['__version__']))
  73. # os.system('git push --tags')
  74. sys.exit()
  75. setup(
  76. app=APP,
  77. name=NAME,
  78. version=about['__version__'],
  79. description="LabelImg is a graphical image annotation tool and label object bounding boxes in images",
  80. long_description=readme + '\n\n' + history,
  81. author="TzuTa Lin",
  82. author_email='tzu.ta.lin@gmail.com',
  83. url='https://github.com/tzutalin/labelImg',
  84. python_requires=REQUIRES_PYTHON,
  85. package_dir={'labelImg': '.'},
  86. packages=required_packages,
  87. entry_points={
  88. 'console_scripts': [
  89. 'labelImg=labelImg.labelImg:main'
  90. ]
  91. },
  92. include_package_data=True,
  93. install_requires=REQUIRED_DEP,
  94. license="MIT license",
  95. zip_safe=False,
  96. keywords='labelImg labelTool development annotation deeplearning',
  97. classifiers=[
  98. 'Development Status :: 5 - Production/Stable',
  99. 'Intended Audience :: Developers',
  100. 'License :: OSI Approved :: MIT License',
  101. 'Natural Language :: English',
  102. 'Programming Language :: Python :: 3',
  103. 'Programming Language :: Python :: 3.3',
  104. 'Programming Language :: Python :: 3.4',
  105. 'Programming Language :: Python :: 3.5',
  106. 'Programming Language :: Python :: 3.6',
  107. 'Programming Language :: Python :: 3.7',
  108. ],
  109. package_data={'data/predefined_classes.txt': ['data/predefined_classes.txt']},
  110. options={'py2app': OPTIONS},
  111. setup_requires=SET_REQUIRES,
  112. # $ setup.py publish support.
  113. cmdclass={
  114. 'upload': UploadCommand,
  115. }
  116. )