Browse Source

Add setup.py to support pip installation

pull/1090/head
Hironsan 4 years ago
parent
commit
6244b0a6d4
4 changed files with 106 additions and 0 deletions
  1. 7
      app/MANIFEST.in
  2. 0
      app/doccano/__init__.py
  3. 44
      app/doccano/doccano.py
  4. 55
      app/setup.py

7
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

0
app/doccano/__init__.py

44
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()

55
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'
],
)
Loading…
Cancel
Save