setup.py 3.3 KB
Newer Older
K
Kentaro Wada 已提交
1
from distutils.spawn import find_executable
K
Fix cwd  
Kentaro Wada 已提交
2
import os.path as osp
3 4
from setuptools.command.develop import develop as DevelopCommand
from setuptools.command.install import install as InstallCommand
K
Kentaro Wada 已提交
5 6 7 8 9 10 11
from setuptools import find_packages
from setuptools import setup
import shlex
import subprocess
import sys


12 13 14 15
PY3 = sys.version_info[0] == 3
PY2 = sys.version_info[0] == 2


K
2.10.2  
Kentaro Wada 已提交
16
version = '2.10.2'
K
2.5.0  
Kentaro Wada 已提交
17 18


19 20
install_requires = [
    'matplotlib',
21
    'numpy',
22 23 24 25 26
    'Pillow>=2.8.0',
    'PyYAML',
]


K
Kentaro Wada 已提交
27 28 29 30 31 32 33 34
try:
    import PyQt5  # NOQA
    PYQT_VERSION = 5
except ImportError:
    try:
        import PyQt4  # NOQA
        PYQT_VERSION = 4
    except ImportError:
35 36 37 38 39 40 41 42
        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')
K
Kentaro Wada 已提交
43
        PYQT_VERSION = 5
K
Kentaro Wada 已提交
44 45


K
2.0.0  
Kentaro Wada 已提交
46
if sys.argv[1] == 'release':
K
Kentaro Wada 已提交
47 48 49
    commands = [
        'git tag v{:s}'.format(version),
        'git push origin master --tag',
50
        'python setup.py sdist upload',
K
Kentaro Wada 已提交
51
    ]
K
Use sum  
Kentaro Wada 已提交
52
    sys.exit(sum(subprocess.call(shlex.split(cmd)) for cmd in commands))
K
Kentaro Wada 已提交
53 54


K
Kentaro Wada 已提交
55 56 57
here = osp.dirname(osp.abspath(__file__))


58 59
def customize(command_subclass):
    orig_run = command_subclass.run
K
Kentaro Wada 已提交
60

61
    def customized_run(self):
K
Kentaro Wada 已提交
62 63 64
        pyrcc = 'pyrcc{:d}'.format(PYQT_VERSION)
        if find_executable(pyrcc) is None:
            sys.stderr.write('Please install {:s} command.\n'.format(pyrcc))
K
Kentaro Wada 已提交
65 66
            sys.stderr.write('(See https://github.com/wkentaro/labelme.git)\n')
            sys.exit(1)
K
Kentaro Wada 已提交
67
        package_dir = osp.join(here, 'labelme')
K
Kentaro Wada 已提交
68 69
        src = 'resources.qrc'
        dst = 'resources.py'
K
Kentaro Wada 已提交
70 71
        cmd = '{pyrcc} -o {dst} {src}'.format(pyrcc=pyrcc, src=src, dst=dst)
        print('+ {:s}'.format(cmd))
K
Kentaro Wada 已提交
72
        subprocess.call(shlex.split(cmd), cwd=package_dir)
73 74 75 76 77 78 79 80 81 82 83 84 85 86
        orig_run(self)

    command_subclass.run = customized_run
    return command_subclass


@customize
class CustomDevelopCommand(DevelopCommand):
    pass


@customize
class CustomInstallCommand(InstallCommand):
    pass
K
Kentaro Wada 已提交
87 88 89 90 91 92


setup(
    name='labelme',
    version=version,
    packages=find_packages(),
93 94 95 96
    cmdclass={
        'develop': CustomDevelopCommand,
        'install': CustomInstallCommand,
    },
K
Kentaro Wada 已提交
97
    description='Image Polygonal Annotation with Python.',
K
Kentaro Wada 已提交
98
    long_description=open('README.md').read(),
K
2.10.1  
Kentaro Wada 已提交
99
    long_description_content_type='text/markdown',
K
Kentaro Wada 已提交
100 101
    author='Kentaro Wada',
    author_email='www.kentaro.wada@gmail.com',
K
Fix url  
Kentaro Wada 已提交
102
    url='https://github.com/wkentaro/labelme',
103
    install_requires=install_requires,
K
Kentaro Wada 已提交
104
    license='GPLv3',
K
Kentaro Wada 已提交
105 106 107 108 109 110 111 112
    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',
    ],
K
Kentaro Wada 已提交
113
    package_data={'labelme': ['icons/*', 'resources.qrc']},
114 115 116 117 118 119 120 121
    entry_points={
        'console_scripts': [
            'labelme=labelme.app:main',
            'labelme_draw_json=labelme.cli.draw_json:main',
            'labelme_json_to_dataset=labelme.cli.json_to_dataset:main',
            'labelme_on_docker=labelme.cli.on_docker:main',
        ],
    },
K
Kentaro Wada 已提交
122
)