-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
158 lines (133 loc) · 4.45 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import distutils.spawn
import os
import re
import shlex
import subprocess
import sys
from setuptools import find_packages
from setuptools import setup
def get_version():
filename = "labelme/__init__.py"
with open(filename) as f:
match = re.search(
r"""^__version__ = ['"]([^'"]*)['"]""", f.read(), re.M
)
if not match:
raise RuntimeError("{} doesn't contain __version__".format(filename))
version = match.groups()[0]
return version
def get_install_requires():
install_requires = [
"imgviz>=0.11",
"matplotlib<3.3", # for PyInstaller
"natsort>=7.1.0",
"numpy",
"Pillow>=2.8",
"PyYAML",
"qtpy!=1.11.2",
"termcolor",
]
# Find python binding for qt with priority:
# PyQt5 -> PySide2
# and PyQt5 is automatically installed on Python3.
QT_BINDING = None
try:
import PyQt5 # NOQA
QT_BINDING = "pyqt5"
except ImportError:
pass
if QT_BINDING is None:
try:
import PySide2 # NOQA
QT_BINDING = "pyside2"
except ImportError:
pass
if QT_BINDING is None:
# PyQt5 can be installed via pip for Python3
# 5.15.3, 5.15.4 won't work with PyInstaller
install_requires.append("PyQt5!=5.15.3,!=5.15.4")
QT_BINDING = "pyqt5"
del QT_BINDING
if os.name == "nt": # Windows
install_requires.append("colorama")
return install_requires
def get_long_description():
with open("README.md") as f:
long_description = f.read()
try:
# when this package is being released
import github2pypi
return github2pypi.replace_url(
slug="wkentaro/labelme", content=long_description, branch="main"
)
except ImportError:
# when this package is being installed
return long_description
def main():
version = get_version()
if sys.argv[1] == "release":
try:
import github2pypi # NOQA
except ImportError:
print(
"Please install github2pypi\n\n\tpip install github2pypi\n",
file=sys.stderr,
)
sys.exit(1)
if not distutils.spawn.find_executable("twine"):
print(
"Please install twine:\n\n\tpip install twine\n",
file=sys.stderr,
)
sys.exit(1)
commands = [
"git push origin main",
"git tag v{:s}".format(version),
"git push origin --tags",
"python setup.py sdist",
"twine upload dist/labelme-{:s}.tar.gz".format(version),
]
for cmd in commands:
print("+ {:s}".format(cmd))
subprocess.check_call(shlex.split(cmd))
sys.exit(0)
setup(
name="labelme",
version=version,
packages=find_packages(),
description="Image Polygonal Annotation with Python",
long_description=get_long_description(),
long_description_content_type="text/markdown",
author="Kentaro Wada",
author_email="[email protected]",
url="https://github.com/wkentaro/labelme",
install_requires=get_install_requires(),
license="GPLv3",
keywords="Image Annotation, Machine Learning",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3 :: Only",
],
package_data={"labelme": ["icons/*", "config/*.yaml"]},
entry_points={
"console_scripts": [
"labelme=labelme.__main__:main",
"labelme_draw_json=labelme.cli.draw_json:main",
"labelme_draw_label_png=labelme.cli.draw_label_png:main",
"labelme_json_to_dataset=labelme.cli.json_to_dataset:main",
"labelme_on_docker=labelme.cli.on_docker:main",
],
},
)
if __name__ == "__main__":
main()