-
Notifications
You must be signed in to change notification settings - Fork 25
/
setup.py
118 lines (96 loc) · 3.1 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from distutils.spawn import find_executable
import os.path as osp
from setuptools.command.develop import develop as DevelopCommand
from setuptools.command.install import install as InstallCommand
from setuptools import find_packages
from setuptools import setup
import shlex
import subprocess
import sys
PY3 = sys.version_info[0] == 3
PY2 = sys.version_info[0] == 2
version = '2.7.0'
install_requires = [
'matplotlib',
'numpy',
'Pillow>=2.8.0',
'PyYAML',
]
try:
import PyQt5 # NOQA
PYQT_VERSION = 5
except ImportError:
try:
import PyQt4 # NOQA
PYQT_VERSION = 4
except ImportError:
if PY2:
sys.stderr.write(
'Please install PyQt4 or PyQt5 for Python2.\n'
'Note that PyQt5 can be installed via pip for Python3.')
sys.exit(1)
assert PY3
# PyQt5 can be installed via pip for Python3
install_requires.append('pyqt5')
if sys.argv[1] == 'release':
commands = [
'git tag v{:s}'.format(version),
'git push origin master --tag',
'python setup.py sdist upload',
]
sys.exit(sum(subprocess.call(shlex.split(cmd)) for cmd in commands))
here = osp.dirname(osp.abspath(__file__))
def customize(command_subclass):
orig_run = command_subclass.run
def customized_run(self):
pyrcc = 'pyrcc{:d}'.format(PYQT_VERSION)
if find_executable(pyrcc) is None:
sys.stderr.write('Please install {:s} command.\n'.format(pyrcc))
sys.stderr.write('(See https://github.com/wkentaro/labelme.git)\n')
sys.exit(1)
package_dir = osp.join(here, 'labelme')
src = 'resources.qrc'
dst = 'resources.py'
cmd = '{pyrcc} -o {dst} {src}'.format(pyrcc=pyrcc, src=src, dst=dst)
print('+ {:s}'.format(cmd))
subprocess.call(shlex.split(cmd), cwd=package_dir)
orig_run(self)
command_subclass.run = customized_run
return command_subclass
@customize
class CustomDevelopCommand(DevelopCommand):
pass
@customize
class CustomInstallCommand(InstallCommand):
pass
setup(
name='labelme',
version=version,
packages=find_packages(),
cmdclass={
'develop': CustomDevelopCommand,
'install': CustomInstallCommand,
},
description='Annotation Tool for Object Segmentation.',
long_description=open('README.md').read(),
author='Kentaro Wada',
author_email='[email protected]',
url='https://github.com/wkentaro/labelme',
install_requires=install_requires,
license='GPLv3',
keywords='Image Annotation, Machine Learning',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX',
'Topic :: Internet :: WWW/HTTP',
],
package_data={'labelme': ['icons/*', 'resources.qrc']},
entry_points={'console_scripts': ['labelme=labelme.app:main']},
scripts=[
'scripts/labelme_draw_json',
'scripts/labelme_json_to_dataset',
'scripts/labelme_on_docker',
],
)