-
Notifications
You must be signed in to change notification settings - Fork 25
/
setup.py
executable file
·144 lines (119 loc) · 4.82 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env python
from distutils.core import setup, Command
import os
import re
import sys
from select_multiple_field import __version__
cmdclasses = dict()
README_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)),
'README.rst')
long_description = open(README_PATH, 'r').read()
class DemoTester(Command):
"""Runs demonstration project tests"""
user_options = []
test_settings = {
'1.4': 'test_projects.django14.django14.settings',
'1.5': 'test_projects.django14.django14.settings',
'1.6': 'test_projects.django14.django14.settings',
'1.7': 'test_projects.django14.django14.settings',
'1.8': 'test_projects.django18.django18.settings',
'1.9': 'test_projects.django18.django18.settings',
}
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
sys.dont_write_bytecode = True
from django import get_version
django_release = re.search(r'^\d\.\d', get_version()).group(0)
test_settings_exist = django_release in self.test_settings.keys()
try:
dj_ver = [int(n) for n in re.split(r'[.ab]', get_version())]
except ValueError:
# Pre-release Djangos must be testable!!!
dj_too_old = False
else:
dj_too_old = dj_ver < [1, 4, 2]
if test_settings_exist is False or dj_too_old:
print("Please install Django 1.4.19 - 1.9 to run the test suite")
exit(-1)
os.environ['DJANGO_SETTINGS_MODULE'] = self.test_settings[
django_release]
try:
from django.core.management import call_command
except ImportError:
print("Please install Django 1.4.19 - 1.9 to run the test suite")
exit(-1)
import django
if hasattr(django, 'setup'):
django.setup()
call_command('test', 'pizzagigi', interactive=False, verbosity=1)
call_command('test', 'forthewing', interactive=False, verbosity=1)
try:
import south
except ImportError:
pass
else:
call_command('test', 'suthern', interactive=False, verbosity=1)
cmdclasses['test_demo'] = DemoTester
class Tester(Command):
"""Runs project unit tests"""
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
sys.dont_write_bytecode = True
os.environ['DJANGO_SETTINGS_MODULE'] = 'test_suite.settings_for_tests'
import django
if hasattr(django, 'setup'):
django.setup()
try:
from django.utils.unittest import TextTestRunner, defaultTestLoader
except ImportError:
from unittest import TextTestRunner, defaultTestLoader
from test_suite import (
test_codecs, test_forms, test_models, test_validators,
test_widgets)
suite = defaultTestLoader.loadTestsFromModule(test_codecs)
suite.addTests(defaultTestLoader.loadTestsFromModule(test_forms))
suite.addTests(defaultTestLoader.loadTestsFromModule(test_models))
suite.addTests(defaultTestLoader.loadTestsFromModule(test_validators))
suite.addTests(defaultTestLoader.loadTestsFromModule(test_widgets))
runner = TextTestRunner()
result = runner.run(suite)
if result.wasSuccessful() is not True:
raise SystemExit(int(bool(result.errors or result.failures)))
cmdclasses['test'] = Tester
setup(
name='django-select-multiple-field',
description='Select multiple choices in a single Django model field',
long_description=long_description,
version=__version__,
license='BSD',
keywords=[
'select', 'select multiple', 'Django', 'model-field',
'Django-Select-Multiple-Field'],
author='Kelvin Wong',
author_email='[email protected]',
url='https://github.com/kelvinwong-ca/django-select-multiple-field',
classifiers=['Development Status :: 3 - Alpha',
# 'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Internet :: WWW/HTTP'],
packages=['select_multiple_field'],
cmdclass=cmdclasses
)