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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
#
|
| 3 |
+
# pyhwp : hwp file format parser in python
|
| 4 |
+
# Copyright (C) 2010-2023 mete0r <https://github.com/mete0r>
|
| 5 |
+
#
|
| 6 |
+
# This program is free software: you can redistribute it and/or modify
|
| 7 |
+
# it under the terms of the GNU Affero General Public License as published by
|
| 8 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 9 |
+
# (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 15 |
+
#
|
| 16 |
+
# You should have received a copy of the GNU Affero General Public License
|
| 17 |
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 18 |
+
from __future__ import absolute_import
|
| 19 |
+
from __future__ import print_function
|
| 20 |
+
from distutils.command.build import build as _build
|
| 21 |
+
import io
|
| 22 |
+
import os.path
|
| 23 |
+
import subprocess
|
| 24 |
+
import sys
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def setupdir(f):
|
| 28 |
+
''' Decorate f to run inside the directory where setup.py resides.
|
| 29 |
+
'''
|
| 30 |
+
setup_dir = os.path.dirname(os.path.abspath(__file__))
|
| 31 |
+
|
| 32 |
+
def wrapped(*args, **kwargs):
|
| 33 |
+
old_dir = os.path.abspath(os.curdir)
|
| 34 |
+
try:
|
| 35 |
+
os.chdir(setup_dir)
|
| 36 |
+
return f(*args, **kwargs)
|
| 37 |
+
finally:
|
| 38 |
+
os.chdir(old_dir)
|
| 39 |
+
|
| 40 |
+
return wrapped
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
@setupdir
|
| 44 |
+
def import_setuptools():
|
| 45 |
+
import setuptools
|
| 46 |
+
return setuptools
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
@setupdir
|
| 50 |
+
def readfile(filename):
|
| 51 |
+
with io.open(filename, 'r', encoding='utf-8') as f:
|
| 52 |
+
return f.read()
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def get_version():
|
| 56 |
+
version = readfile('VERSION.txt')
|
| 57 |
+
version = version.strip()
|
| 58 |
+
return version
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def get_long_description():
|
| 62 |
+
long_description = readfile('README') + '\n' + readfile('CHANGES')
|
| 63 |
+
return long_description
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def get_classifiers():
|
| 67 |
+
return [
|
| 68 |
+
'Development Status :: 4 - Beta',
|
| 69 |
+
'Intended Audience :: Developers',
|
| 70 |
+
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
|
| 71 |
+
'Programming Language :: Python :: 3',
|
| 72 |
+
'Programming Language :: Python :: 3.11',
|
| 73 |
+
'Topic :: Software Development :: Libraries :: Python Modules',
|
| 74 |
+
'Topic :: Text Processing',
|
| 75 |
+
]
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def get_install_requires():
|
| 79 |
+
requires = readfile('requirements.in')
|
| 80 |
+
requires = requires.strip()
|
| 81 |
+
requires = requires.split('\n')
|
| 82 |
+
requires = list(requires)
|
| 83 |
+
return requires
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
class build(_build):
|
| 87 |
+
def run(self):
|
| 88 |
+
#
|
| 89 |
+
# compile message catalogs
|
| 90 |
+
#
|
| 91 |
+
domains = [
|
| 92 |
+
'hwp5proc',
|
| 93 |
+
'hwp5html',
|
| 94 |
+
'hwp5odt',
|
| 95 |
+
'hwp5txt',
|
| 96 |
+
'hwp5view',
|
| 97 |
+
]
|
| 98 |
+
# Skip compilation for now or handle it gracefully
|
| 99 |
+
# for domain in domains:
|
| 100 |
+
# args = [
|
| 101 |
+
# sys.executable,
|
| 102 |
+
# __file__,
|
| 103 |
+
# 'compile_catalog',
|
| 104 |
+
# '--domain={}'.format(domain)
|
| 105 |
+
# ]
|
| 106 |
+
# subprocess.check_call(args)
|
| 107 |
+
|
| 108 |
+
#
|
| 109 |
+
# process to normal build operations
|
| 110 |
+
#
|
| 111 |
+
_build.run(self)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
setup_info = {
|
| 115 |
+
|
| 116 |
+
# basic information
|
| 117 |
+
|
| 118 |
+
'name': 'pyhwp2',
|
| 119 |
+
'version': get_version(),
|
| 120 |
+
'description': 'hwp file format parser',
|
| 121 |
+
'long_description': get_long_description(),
|
| 122 |
+
|
| 123 |
+
# authorative
|
| 124 |
+
|
| 125 |
+
'author': 'mete0r',
|
| 126 |
+
'author_email': '137794+mete0r@users.noreply.github.com',
|
| 127 |
+
'license': 'GNU Affero General Public License v3 or later (AGPLv3+)',
|
| 128 |
+
'url': 'https://github.com/mete0r/pyhwp',
|
| 129 |
+
|
| 130 |
+
# classifying
|
| 131 |
+
|
| 132 |
+
'classifiers': get_classifiers(),
|
| 133 |
+
|
| 134 |
+
'keywords': 'hwp',
|
| 135 |
+
|
| 136 |
+
# packaging
|
| 137 |
+
|
| 138 |
+
'setup_requires': [
|
| 139 |
+
'babel',
|
| 140 |
+
],
|
| 141 |
+
|
| 142 |
+
'packages': [
|
| 143 |
+
'hwp5',
|
| 144 |
+
'hwp5.binmodel',
|
| 145 |
+
'hwp5.binmodel.controls',
|
| 146 |
+
'hwp5.plat',
|
| 147 |
+
'hwp5.plat._uno',
|
| 148 |
+
'hwp5.proc',
|
| 149 |
+
'hwp5.storage',
|
| 150 |
+
'hwp5.transforms',
|
| 151 |
+
'pyhwp',
|
| 152 |
+
],
|
| 153 |
+
# do not use '.'; just omit to specify setup.py directory
|
| 154 |
+
'package_dir': {
|
| 155 |
+
'': 'src',
|
| 156 |
+
},
|
| 157 |
+
|
| 158 |
+
'package_data': {
|
| 159 |
+
'hwp5': [
|
| 160 |
+
'README',
|
| 161 |
+
'COPYING',
|
| 162 |
+
'VERSION.txt',
|
| 163 |
+
'xsl/*.xsl',
|
| 164 |
+
'xsl/odt/*.xsl',
|
| 165 |
+
'odf-relaxng/OpenDocument-v1.2-os-*.rng',
|
| 166 |
+
'locale/*/*/*.mo',
|
| 167 |
+
],
|
| 168 |
+
},
|
| 169 |
+
|
| 170 |
+
'python_requires': '>=3.6',
|
| 171 |
+
|
| 172 |
+
# installation
|
| 173 |
+
|
| 174 |
+
'zip_safe': False,
|
| 175 |
+
|
| 176 |
+
'entry_points': {
|
| 177 |
+
'console_scripts': [
|
| 178 |
+
'hwp2html=pyhwp.html_converter:main',
|
| 179 |
+
'hwp5spec=hwp5.binspec:main',
|
| 180 |
+
'hwp5proc=hwp5.hwp5proc:main',
|
| 181 |
+
'hwp5odt=hwp5.hwp5odt:main',
|
| 182 |
+
'hwp5txt=hwp5.hwp5txt:main',
|
| 183 |
+
'hwp5html=hwp5.hwp5html:main',
|
| 184 |
+
'hwp5view=hwp5.hwp5view:main',
|
| 185 |
+
]
|
| 186 |
+
},
|
| 187 |
+
|
| 188 |
+
'install_requires': get_install_requires(),
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
@setupdir
|
| 193 |
+
def main():
|
| 194 |
+
setuptools = import_setuptools()
|
| 195 |
+
setup_info['cmdclass'] = {
|
| 196 |
+
'build': build,
|
| 197 |
+
}
|
| 198 |
+
setuptools.setup(**setup_info)
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
if __name__ == '__main__':
|
| 202 |
+
main()
|