Browse Source

Merge pull request #1100 from doccano/fix/#1095

Fix pg_config error on pip installation
pull/1104/head
Hiroki Nakayama 3 years ago
committed by GitHub
parent
commit
b08346ef6e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 16 deletions
  1. 6
      README.md
  2. 19
      app/app/settings.py
  3. 8
      app/doccano/doccano.py
  4. 11
      setup.py

6
README.md

@ -1,5 +1,5 @@
<div align="center">
<img src="./docs/images/logo/doccano.png">
<img src="https://raw.githubusercontent.com/doccano/doccano/master/docs/images/logo/doccano.png">
</div>
# doccano
@ -13,7 +13,7 @@ doccano is an open source text annotation tool for humans. It provides annotatio
You can try the [annotation demo](http://doccano.herokuapp.com).
![Demo image](./docs/images/demo/demo.gif)
![Demo image](https://raw.githubusercontent.com/doccano/doccano/master/docs/images/demo/demo.gif)
## Features
@ -54,7 +54,7 @@ After installation, simply run the following command:
doccano
```
Go to <http://0.0.0.0:{YOUR_PORT}/>.
Go to <http://0.0.0.0:8000/>.
### Docker

19
app/app/settings.py

@ -10,9 +10,10 @@ https://docs.djangoproject.com/en/2.0/ref/settings/
Any setting that is configured via an environment variable may
also be set in a `.env` file in the project base directory.
"""
import importlib.util
import sys
from os import path
import django_heroku
import dj_database_url
from environs import Env
from furl import furl
@ -53,13 +54,13 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'server.apps.ServerConfig',
'api.apps.ApiConfig',
'widget_tweaks',
# 'widget_tweaks',
'rest_framework',
'rest_framework.authtoken',
'django_filters',
'social_django',
'polymorphic',
'webpack_loader',
# 'webpack_loader',
'corsheaders',
'drf_yasg'
]
@ -83,7 +84,7 @@ MIDDLEWARE = [
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
'applicationinsights.django.ApplicationInsightsMiddleware',
# 'applicationinsights.django.ApplicationInsightsMiddleware',
'corsheaders.middleware.CorsMiddleware',
]
@ -277,7 +278,13 @@ LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/projects/'
LOGOUT_REDIRECT_URL = '/'
django_heroku.settings(locals(), test_runner=False)
# dynamic import to avoid installing psycopg2 on pip installation.
name = 'django_heroku'
if (spec := importlib.util.find_spec(name)) is not None:
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
module.settings(locals(), test_runner=False)
# Change 'default' database configuration with $DATABASE_URL.
DATABASES['default'].update(dj_database_url.config(
@ -309,7 +316,7 @@ CSRF_COOKIE_SECURE = env.bool('CSRF_COOKIE_SECURE', False)
CSRF_TRUSTED_ORIGINS = env.list('CSRF_TRUSTED_ORIGINS', [])
# Allow all host headers
# ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = ['*']
# Size of the batch for creating documents
# on the import phase

8
app/doccano/doccano.py

@ -4,13 +4,13 @@ import subprocess
def main():
parser = argparse.ArgumentParser(description='doccano.')
parser = argparse.ArgumentParser(description='doccano, text annotation for machine learning practitioners.')
parser.add_argument('--username', type=str, default='admin', help='admin username')
parser.add_argument('--password', type=str, default='password', help='admin password')
parser.add_argument('--email', type=str, default='example@example.com', help='admin email')
parser.add_argument('--port', type=int, default=8000, help='port')
parser.add_argument('--workers', type=int, default=1, help='workers')
parser.add_argument('--database_url', type=str, default='sqlite:///doccano.db', help='data store')
parser.add_argument('--port', type=int, default=8000, help='port number')
# parser.add_argument('--workers', type=int, default=1, help='the number of workers')
parser.add_argument('--database_url', type=str, default='sqlite:///doccano.db', help='the database URL')
args = parser.parse_args()
os.environ.setdefault('DEBUG', 'False')

11
setup.py

@ -6,7 +6,7 @@ import os
from setuptools import find_packages, setup
NAME = 'doccano'
DESCRIPTION = 'doccano'
DESCRIPTION = 'doccano, text annotation tool for machine learning practitioners'
URL = 'https://github.com/doccano/doccano'
EMAIL = 'hiroki.nakayama.py@gmail.com'
AUTHOR = 'Hironsan'
@ -16,8 +16,9 @@ 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()
# required = ['requests', 'boto3', 'pydantic', 'jinja2']
required = [line.rstrip() for line in io.open(os.path.join(here, 'app/requirements.txt')) if not line.startswith('psy')]
# Todo: make a cleaned requirements.txt
required = [line.rstrip() for line in io.open(os.path.join(here, 'app/requirements.txt'))
if not line.startswith(('psycopg2', 'django-heroku', 'django-mssql-backend'))]
setup(
name=NAME,
@ -36,6 +37,10 @@ setup(
]
},
install_requires=required,
extras_require={
'postgresql': ['psycopg2-binary>=2.8.6'],
'mssql': ['django-mssql-backend>=2.8.1'],
},
include_package_data=True,
license=LICENSE,
classifiers=[

Loading…
Cancel
Save