Last active
May 24, 2019 11:51
-
-
Save ratsgo/ae99a267abc47506a767622aa682c65a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Kakao Hangul Analyzer III | |
__version__ = '0.3' | |
__author__ = 'Kakao Corp.' | |
__copyright__ = 'Copyright (C) 2018-, Kakao Corp. All rights reserved.' | |
__license__ = 'Apache 2.0' | |
__maintainer__ = 'Jamie' | |
__email__ = '[email protected]' | |
""" | |
########### | |
# imports # | |
########### | |
from distutils.command.build import build | |
import os | |
import shutil | |
import subprocess | |
import zipfile | |
from setuptools import setup | |
############# | |
# constants # | |
############# | |
_SRC_NAME = 'khaiii-0.3' | |
######### | |
# types # | |
######### | |
class CustomBuild(build): | |
""" | |
custom handler for 'build' command | |
""" | |
def run(self): | |
""" | |
run build command | |
""" | |
with zipfile.ZipFile('{}.zip'.format(_SRC_NAME), 'r') as src_zip: | |
src_zip.extractall() | |
build_dir = '{}/build'.format(_SRC_NAME) | |
os.makedirs(build_dir, exist_ok=True) | |
subprocess.check_call('cmake ..', cwd=build_dir, shell=True) | |
subprocess.check_call('make all resource', cwd=build_dir, shell=True) | |
shutil.rmtree('khaiii/lib', ignore_errors=True) | |
shutil.copytree('{}/lib'.format(build_dir), 'khaiii/lib') | |
shutil.rmtree('khaiii/share', ignore_errors=True) | |
shutil.copytree('{}/share'.format(build_dir), 'khaiii/share') | |
shutil.rmtree(_SRC_NAME) | |
build.run(self) | |
############# | |
# functions # | |
############# | |
def readme(): | |
""" | |
read content from README.md file | |
Returns: | |
long description (content of README.md) | |
""" | |
return open('/notebooks/khaiii/README.md', 'r', encoding='UTF-8').read() | |
######### | |
# setup # | |
######### | |
setup( | |
name='khaiii', | |
version='0.3', | |
description='Kakao Hangul Analyzer III', | |
long_description=readme(), | |
url='https://github.com/kakao/khaiii', | |
author='Kakao Corp.', | |
author_email='[email protected]', | |
classifiers=[ | |
'Development Status :: 5 - Stable', | |
'License :: OSI Approved :: Apache 2.0', | |
'Programming Language :: Python :: 3', | |
'Programming Language :: Python :: 3.6', | |
], | |
license='Apache 2.0', | |
packages=['khaiii', ], | |
include_package_data=True, | |
install_requires=[], | |
setup_requires=['cmake>=3.10', 'pytest-runner'], | |
tests_require=['pytest', ], | |
zip_safe=False, | |
cmdclass={'build': CustomBuild} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment