-
Notifications
You must be signed in to change notification settings - Fork 20
/
setup.py
executable file
·115 lines (101 loc) · 3.6 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env python
import os
import sys
from setuptools import find_packages
from setuptools import setup
from setuptools.command.test import test as TestCommand
tests_require = (
'pytest>=6.2.5,<7.5',
'pytest-django',
)
install_requires = (
'Django>=3.2,<4.3',
'richenum',
)
class DjangoTest(TestCommand):
DIRNAME = os.path.dirname(__file__)
APPS = ('tests',)
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import django
import pytest
from django.conf import settings
db_host = os.environ.get('DJANGO_DB_HOST')
db_engine = os.environ.get('DJANGO_DB_ENGINE', 'sqlite')
db_user = os.environ.get('DJANGO_DB_USER')
db_pass = os.environ.get('DJANGO_DB_PASSWORD')
if db_engine == 'mysql':
db_settings = {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'testdb',
'USER': db_user or 'root',
'HOST': db_host,
'PASSWORD': db_pass
}
elif db_engine == 'postgres':
db_settings = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'testdb',
'USER': db_user or 'postgres',
'HOST': db_host,
'PASSWORD': db_pass
}
elif db_engine == 'sqlite':
db_settings = {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(self.DIRNAME, 'database.db'),
}
else:
raise ValueError("Unknown DB engine: %s" % db_engine)
settings.configure(
DEBUG=True,
DATABASES={'default': db_settings},
SECRET_KEY=os.environ.get('SECRET_KEY'),
CACHES={
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache'
}
},
MIDDLEWARE_CLASSES=['django.middleware.common.CommonMiddleware'],
INSTALLED_APPS=(
# Default Django apps from settings template
# https://github.com/django/django/blob/2.1/django/conf/project_template/project_name/settings.py-tpl
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles') + self.APPS)
django.setup()
sys.exit(pytest.main(["tests/"]))
setup(
name='django-richenum',
version='5.0.0',
description='Django Enum library for python.',
long_description=(
open('README.rst').read() + '\n\n' +
open('CHANGELOG.rst').read() + '\n\n' +
open('AUTHORS.rst').read()),
classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: Implementation :: CPython',
],
keywords='python django enum richenum',
url='https://github.com/hearsaycorp/django-richenum',
author='Hearsay Social',
author_email='opensource@hearsaysocial.com',
license='MIT',
package_dir={'': 'src'},
packages=find_packages('src'),
install_requires=install_requires,
tests_require=tests_require,
cmdclass={'test': DjangoTest},
)