CoolFace
Apppublic

Heartsync/toss-hwp

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
setup.py203 linesDownload Raw Back to root
1# -*- coding: utf-8 -*-2#3#   pyhwp : hwp file format parser in python4#   Copyright (C) 2010-2023 mete0r <https://github.com/mete0r>5#6#   This program is free software: you can redistribute it and/or modify7#   it under the terms of the GNU Affero General Public License as published by8#   the Free Software Foundation, either version 3 of the License, or9#   (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 of13#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the14#   GNU Affero General Public License for more details.15#16#   You should have received a copy of the GNU Affero General Public License17#   along with this program.  If not, see <http://www.gnu.org/licenses/>.18from __future__ import absolute_import19from __future__ import print_function20from distutils.command.build import build as _build21import io22import os.path23import subprocess24import sys25 26 27def 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 wrapped41 42 43@setupdir44def import_setuptools():45    import setuptools46    return setuptools47 48 49@setupdir50def readfile(filename):51    with io.open(filename, 'r', encoding='utf-8') as f:52        return f.read()53 54 55def get_version():56    version = readfile('VERSION.txt')57    version = version.strip()58    return version59 60 61def get_long_description():62    long_description = readfile('README') + '\n' + readfile('CHANGES')63    return long_description64 65 66def 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 78def get_install_requires():79    requires = readfile('requirements.in')80    requires = requires.strip()81    requires = requires.split('\n')82    requires = list(requires)83    return requires84 85 86class build(_build):87    def run(self):88        #89        # compile message catalogs90        #91        domains = [92            'hwp5proc',93            'hwp5html',94            'hwp5odt',95            'hwp5txt',96            'hwp5view',97        ]98        # Skip compilation for now or handle it gracefully99        # 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 operations110        #111        _build.run(self)112 113 114setup_info = {115 116    # basic information117 118    'name': 'pyhwp2',119    'version': get_version(),120    'description': 'hwp file format parser',121    'long_description': get_long_description(),122 123    # authorative124 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    # classifying131 132    'classifiers': get_classifiers(),133 134    'keywords': 'hwp',135 136    # packaging137 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 directory154    '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    # installation173 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@setupdir193def main():194    setuptools = import_setuptools()195    setup_info['cmdclass'] = {196        'build': build,197    }198    setuptools.setup(**setup_info)199 200 201if __name__ == '__main__':202    main()203