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


K
2.0.3  
Kentaro Wada 已提交
11
version = '2.0.3'
K
2.0.0  
Kentaro Wada 已提交
12 13 14 15


if sys.argv[1] == 'release':
    for cmd in [
K
2.0.1  
Kentaro Wada 已提交
16
            'python setup.py sdist upload',
K
2.0.0  
Kentaro Wada 已提交
17
            'git tag v{0}'.format(version),
K
2.0.1  
Kentaro Wada 已提交
18
            'git push origin master --tag']:
K
2.0.0  
Kentaro Wada 已提交
19
        subprocess.call(shlex.split(cmd))
K
2.0.2  
Kentaro Wada 已提交
20
    sys.exit(0)
K
Kentaro Wada 已提交
21 22 23 24 25


class LabelmeBuildPyCommand(BuildPyCommand):

    def run(self):
K
Kentaro Wada 已提交
26 27 28 29
        if find_executable('pyrcc4') is None:
            sys.stderr.write('Please install pyrcc4 command.\n')
            sys.stderr.write('(See https://github.com/wkentaro/labelme.git)\n')
            sys.exit(1)
K
Kentaro Wada 已提交
30 31 32 33 34 35
        this_dir = osp.dirname(osp.abspath(__file__))
        package_dir = osp.join(this_dir, 'labelme')
        src = 'resources.qrc'
        dst = 'resources.py'
        print('converting {0} -> {1}'
              .format(osp.join(package_dir, src), osp.join(package_dir, dst)))
K
Fix cwd  
Kentaro Wada 已提交
36
        cmd = 'pyrcc4 -o {1} {0}'.format(src, dst)
K
Kentaro Wada 已提交
37
        subprocess.call(shlex.split(cmd), cwd=package_dir)
38
        BuildPyCommand.run(self)
K
Kentaro Wada 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53


try:
    import PyQt4
except ImportError:
    sys.stderr.write('Please install PyQt4.\n')
    sys.exit(1)


setup(
    name='labelme',
    version=version,
    packages=find_packages(),
    cmdclass={'build_py': LabelmeBuildPyCommand},
    description='Simple Image Annotation Tool.',
K
Kentaro Wada 已提交
54
    long_description=open('README.rst').read(),
K
Kentaro Wada 已提交
55 56
    author='Kentaro Wada',
    author_email='www.kentaro.wada@gmail.com',
K
Kentaro Wada 已提交
57 58
    url='https://github.com/mpitid/pylabelme',
    install_requires=[],
K
Kentaro Wada 已提交
59
    license='GPLv3',
K
Kentaro Wada 已提交
60 61 62 63 64 65 66 67
    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 已提交
68
    package_data={'labelme': ['icons/*', 'resources.qrc']},
K
Kentaro Wada 已提交
69
    entry_points={'console_scripts': ['labelme=labelme.app:main']},
K
Kentaro Wada 已提交
70
    scripts=['scripts/labelme_draw_json'],
K
Kentaro Wada 已提交
71
)