Repository navigation
Expand file tree
/
Copy pathsetup.py.in
More file actions
95 lines (81 loc) · 2.3 KB
/
Copy pathsetup.py.in
File metadata and controls
95 lines (81 loc) · 2.3 KB
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
# -*- coding: utf-8 -*-
"""
@CPACK_PACKAGE_DESCRIPTION_SUMMARY@
__version__ = '@KHAIII_VERSION@'
__author__ = '@CPACK_PACKAGE_VENDOR@'
__copyright__ = 'Copyright (C) 2018-, Kakao Corp. All rights reserved.'
__license__ = 'Apache 2.0'
__maintainer__ = 'Jamie'
__email__ = 'jamie.lim@kakaocorp.com'
"""
###########
# imports #
###########
from distutils.command.build import build
import os
import shutil
import subprocess
import zipfile
from setuptools import setup
#############
# constants #
#############
_SRC_NAME = '@CPACK_SOURCE_PACKAGE_FILE_NAME@'
#########
# 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('@CMAKE_SOURCE_DIR@/README.md', 'r', encoding='UTF-8').read()
#########
# setup #
#########
setup(
name='khaiii',
version='@KHAIII_VERSION@',
description='@CPACK_PACKAGE_DESCRIPTION_SUMMARY@',
long_description=readme(),
url='https://github.com/kakao/khaiii',
author='@CPACK_PACKAGE_VENDOR@',
author_email='jamie.lim@kakaocorp.com',
classifiers=[
'Development Status :: 5 - Stable',
'License :: OSI Approved :: Apache 2.0',
'Programming Language :: Python :: 3',
],
license='Apache 2.0',
packages=['khaiii', ],
include_package_data=True,
install_requires=[],
setup_requires=['pytest-runner', ],
tests_require=['pytest', ],
zip_safe=False,
cmdclass={'build': CustomBuild}
)