diff --git a/app/MANIFEST.in b/app/MANIFEST.in new file mode 100644 index 00000000..e9e17c0c --- /dev/null +++ b/app/MANIFEST.in @@ -0,0 +1,7 @@ +include manage.py +include requirements.txt +include README.md +graft staticfiles +graft client +graft doccano +global-exclude *.pyc diff --git a/app/doccano/__init__.py b/app/doccano/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/app/doccano/doccano.py b/app/doccano/doccano.py new file mode 100644 index 00000000..16f255d6 --- /dev/null +++ b/app/doccano/doccano.py @@ -0,0 +1,44 @@ +import argparse +import os +import subprocess + + +def main(): + parser = argparse.ArgumentParser(prog='gfg', description='GfG article demo package.') + parser.add_argument('--username', type=str, default='admin') + parser.add_argument('--password', type=str, default='password') + parser.add_argument('--email', type=str, default='example@example.com') + parser.add_argument('--port', type=int, default=8000) + parser.add_argument('--workers', type=int, default=1) + args = parser.parse_args() + + print('Create staticfiles.') + # subprocess.call(['python', 'manage.py', 'collectstatic', '--noinput'], shell=False) + + print('Setup databse.') + base = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + #base = os.path.abspath(os.path.dirname(__file__)) + # manage_path = os.path.join(base, 'app/manage.py') + manage_path = os.path.join(base, 'manage.py') + print(manage_path) + subprocess.call(['python', manage_path, 'wait_for_db'], shell=False) + subprocess.call(['python', manage_path, 'migrate'], shell=False) + subprocess.call(['python', manage_path, 'create_roles'], shell=False) + + print('Create admin user.') + subprocess.call(['python', manage_path, 'create_admin', + '--username', args.username, + '--password', args.password, + '--email', args.email, + '--noinput'], shell=False) + + print(f'Starting server with port {args.port}.') + subprocess.call(['gunicorn', + '--bind', f'0.0.0.0:{args.port}', + '--workers', str(args.workers), + 'app.wsgi', + '--timeout', '300'], shell=False) + + +if __name__ == '__main__': + main() diff --git a/app/setup.py b/app/setup.py new file mode 100644 index 00000000..cc17f416 --- /dev/null +++ b/app/setup.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import io +import os +import sys + +from setuptools import find_packages, setup + +NAME = 'doccano' +DESCRIPTION = 'doccano' +URL = 'https://github.com/doccano/doccano' +EMAIL = 'hiroki.nakayama.py@gmail.com' +AUTHOR = 'Hironsan' +LICENSE = 'MIT' + +here = os.path.abspath(os.path.dirname(__file__)) +with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f: + long_description = '\n' + f.read() + +if sys.argv[-1] == 'publish': + os.system('python setup.py sdist bdist_wheel upload') + sys.exit() + +# required = ['requests', 'boto3', 'pydantic', 'jinja2'] +required = [line.rstrip() for line in io.open(os.path.join(here, 'requirements.txt')) if not line.startswith('psy')] + +setup( + name=NAME, + use_scm_version={'root': '..'}, + setup_requires=['setuptools_scm'], + description=DESCRIPTION, + long_description=long_description, + long_description_content_type='text/markdown', + author=AUTHOR, + author_email=EMAIL, + url=URL, + packages=find_packages(exclude=('*.tests',)), + entry_points={ + 'console_scripts': [ + 'doccano = doccano.doccano:main' + ] + }, + install_requires=required, + include_package_data=True, + license=LICENSE, + classifiers=[ + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy' + ], +)