import unittest

from Cython.Build import cythonize
from distutils.core import Command
from distutils.core import setup
from distutils.extension import Extension


class TestCmd(Command):
    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):
        runner = unittest.TextTestRunner(verbosity=2)
        runner.run(unittest.defaultTestLoader.discover('tests'))

setup(
    ext_modules=cythonize([
        Extension(
            'embedded_jubatus',
            [
                'src/embedded_jubatus.pyx',
                'src/_wrapper.cpp',
                'src/_model.cpp'
            ],
            libraries=['jubatus_core', 'jubaserv_common'],
            language='c++')
    ]),
    cmdclass={'test': TestCmd},
)

@@ -1,21 +1,4 @@
-import unittest%0A%0A
 from
@@ -37,401 +37,121 @@
 rom 
-distutils.core import Command%0Afrom distutils.core import setup%0Afrom distutils.extension import Extension%0A%0A%0Aclass TestCmd(Command):%0A    user_options = %5B%5D%0A%0A    def initialize_options(self):%0A        pass%0A%0A    def finalize_options(self):%0A        pass%0A%0A    def run(self):%0A        runner = unittest.TextTestRunner(verbosity=2)%0A        runner.run(unittest.defaultTestLoader.discover('tests'))%0A%0Asetup(
+setuptools import Extension%0Afrom setuptools import setup%0A%0A%0Asetup(%0A    name='embedded_jubatus',%0A    version='0.1',
 %0A   
@@ -471,34 +471,60 @@
     
-cmdclass=%7B'test': TestCmd%7D
+install_requires=%5B'jubatus'%5D,%0A    test_suite='tests'
 ,%0A)%0A

switch from distutils to setuptools