|
1
|
|
|
# coding=utf-8 |
|
2
|
|
|
import sys |
|
3
|
|
|
import os |
|
4
|
|
|
from setuptools import setup, find_packages, Command |
|
5
|
|
|
from setuptools.command.sdist import sdist as original_sdist |
|
6
|
|
|
|
|
7
|
|
|
NAME = 'django-inspectional-registration' |
|
8
|
|
|
VERSION = '0.6.0' |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
View Code Duplication |
class compile_docs(Command): |
|
|
|
|
|
|
12
|
|
|
description = ("re-compile documentations") |
|
13
|
|
|
user_options = [] |
|
14
|
|
|
|
|
15
|
|
|
def initialize_options(self): |
|
16
|
|
|
self.cwd = None |
|
17
|
|
|
|
|
18
|
|
|
def finalize_options(self): |
|
19
|
|
|
self.cwd = os.getcwd() |
|
20
|
|
|
|
|
21
|
|
|
def run(self): |
|
22
|
|
|
compile_docs.compile_docs() |
|
23
|
|
|
|
|
24
|
|
|
@classmethod |
|
25
|
|
|
def compile_docs(cls): |
|
26
|
|
|
""" |
|
27
|
|
|
Compile '.rst' files into '.html' files via Sphinx. |
|
28
|
|
|
""" |
|
29
|
|
|
original_cwd = os.getcwd() |
|
30
|
|
|
BASE = os.path.abspath(os.path.dirname(__file__)) |
|
31
|
|
|
root = os.path.join(BASE, 'docs') |
|
32
|
|
|
os.chdir(root) |
|
33
|
|
|
os.system('make html') |
|
34
|
|
|
os.system('xdg-open _build/html/index.html') |
|
35
|
|
|
os.chdir(original_cwd) |
|
36
|
|
|
return True |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
View Code Duplication |
class compile_messages(Command): |
|
|
|
|
|
|
40
|
|
|
description = ("re-compile local message files ('.po' to '.mo'). " |
|
41
|
|
|
"it require django-admin.py") |
|
42
|
|
|
user_options = [] |
|
43
|
|
|
|
|
44
|
|
|
def initialize_options(self): |
|
45
|
|
|
self.cwd = None |
|
46
|
|
|
|
|
47
|
|
|
def finalize_options(self): |
|
48
|
|
|
self.cwd = os.getcwd() |
|
49
|
|
|
|
|
50
|
|
|
def run(self): |
|
51
|
|
|
compile_messages.compile_messages() |
|
52
|
|
|
|
|
53
|
|
|
@classmethod |
|
54
|
|
|
def compile_messages(cls): |
|
55
|
|
|
""" |
|
56
|
|
|
Compile '.po' into '.mo' via 'django-admin.py' thus the function |
|
57
|
|
|
require the django to be installed. |
|
58
|
|
|
|
|
59
|
|
|
It return True when the process successfully end, otherwise it print |
|
60
|
|
|
error messages and return False. |
|
61
|
|
|
|
|
62
|
|
|
https://docs.djangoproject.com/en/dev/ref/django-admin/#compilemessages |
|
63
|
|
|
""" |
|
64
|
|
|
try: |
|
65
|
|
|
import django |
|
66
|
|
|
except ImportError: |
|
67
|
|
|
print('####################################################\n' |
|
68
|
|
|
'Django is not installed.\nIt will not be possible to ' |
|
69
|
|
|
'compile the locale files during installation of ' |
|
70
|
|
|
'django-inspectional-registration.\nPlease, install ' |
|
71
|
|
|
'Django first. Done so, install the django-registration' |
|
72
|
|
|
'-inspectional\n' |
|
73
|
|
|
'####################################################\n') |
|
74
|
|
|
return False |
|
75
|
|
|
else: |
|
76
|
|
|
original_cwd = os.getcwd() |
|
77
|
|
|
BASE = os.path.abspath(os.path.dirname(__file__)) |
|
78
|
|
|
root = os.path.join(BASE, 'src/registration') |
|
79
|
|
|
os.chdir(root) |
|
80
|
|
|
os.system('django-admin.py compilemessages') |
|
81
|
|
|
os.chdir(original_cwd) |
|
82
|
|
|
return True |
|
83
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
class sdist(original_sdist): |
|
86
|
|
|
""" |
|
87
|
|
|
Run 'sdist' command but make sure that the message files are latest by |
|
88
|
|
|
running 'compile_messages' before 'sdist' |
|
89
|
|
|
""" |
|
90
|
|
|
def run(self): |
|
91
|
|
|
compile_messages.compile_messages() |
|
92
|
|
|
original_sdist.run(self) |
|
93
|
|
|
|
|
94
|
|
|
|
|
95
|
|
|
def read(filename): |
|
96
|
|
|
import os |
|
97
|
|
|
BASE_DIR = os.path.dirname(__file__) |
|
98
|
|
|
filename = os.path.join(BASE_DIR, filename) |
|
99
|
|
|
with open(filename, 'r') as fi: |
|
100
|
|
|
return fi.read() |
|
101
|
|
|
|
|
102
|
|
|
|
|
103
|
|
|
def readlist(filename): |
|
104
|
|
|
rows = read(filename).split("\n") |
|
105
|
|
|
rows = [x.strip() for x in rows if x.strip()] |
|
106
|
|
|
return list(rows) |
|
107
|
|
|
|
|
108
|
|
|
# if we are running on python 3, enable 2to3 and |
|
109
|
|
|
# let it use the custom fixers from the custom_fixers |
|
110
|
|
|
# package. |
|
111
|
|
|
extra = {} |
|
112
|
|
|
if sys.version_info >= (3, 0): |
|
113
|
|
|
extra.update( |
|
114
|
|
|
use_2to3=True, |
|
115
|
|
|
) |
|
116
|
|
|
|
|
117
|
|
|
setup( |
|
118
|
|
|
name=NAME, |
|
119
|
|
|
version=VERSION, |
|
120
|
|
|
description=("Django registration app which required inspection step " |
|
121
|
|
|
"before activation"), |
|
122
|
|
|
long_description = read('README.rst'), |
|
123
|
|
|
classifiers = ( |
|
124
|
|
|
'Development Status :: 5 - Production/Stable', |
|
125
|
|
|
'Environment :: Web Environment', |
|
126
|
|
|
'Framework :: Django', |
|
127
|
|
|
'Intended Audience :: Developers', |
|
128
|
|
|
'License :: OSI Approved :: MIT License', |
|
129
|
|
|
'Operating System :: OS Independent', |
|
130
|
|
|
'Programming Language :: Python', |
|
131
|
|
|
'Programming Language :: Python :: 2', |
|
132
|
|
|
'Programming Language :: Python :: 2.6', |
|
133
|
|
|
'Programming Language :: Python :: 2.7', |
|
134
|
|
|
'Programming Language :: Python :: 3', |
|
135
|
|
|
'Programming Language :: Python :: 3.2', |
|
136
|
|
|
'Programming Language :: Python :: 3.3', |
|
137
|
|
|
'Programming Language :: Python :: 3.4', |
|
138
|
|
|
'Topic :: Internet :: WWW/HTTP', |
|
139
|
|
|
'Topic :: Software Development :: Libraries', |
|
140
|
|
|
'Topic :: Software Development :: Libraries :: Application Frameworks', |
|
141
|
|
|
'Topic :: Software Development :: Libraries :: Python Modules', |
|
142
|
|
|
), |
|
143
|
|
|
keywords = "django app registration inspection", |
|
144
|
|
|
author = 'Alisue', |
|
145
|
|
|
author_email = '[email protected]', |
|
146
|
|
|
url = 'https://github.com/lambdalisue/%s' % NAME, |
|
147
|
|
|
download_url = 'https://github.com/lambdalisue/%s/tarball/master' % NAME, |
|
148
|
|
|
license = 'MIT', |
|
149
|
|
|
packages = find_packages('src'), |
|
150
|
|
|
package_dir = {'': 'src'}, |
|
151
|
|
|
include_package_data = True, |
|
152
|
|
|
package_data = { |
|
153
|
|
|
'': ['README.rst', |
|
154
|
|
|
'requirements.txt', |
|
155
|
|
|
'requirements-test.txt', |
|
156
|
|
|
'requirements-docs.txt'], |
|
157
|
|
|
}, |
|
158
|
|
|
zip_safe=True, |
|
159
|
|
|
install_requires=readlist('requirements.txt'), |
|
160
|
|
|
test_suite='runtests.run_tests', |
|
161
|
|
|
tests_require=readlist('requirements-test.txt'), |
|
162
|
|
|
cmdclass={ |
|
163
|
|
|
'compile_messages': compile_messages, |
|
164
|
|
|
'compile_docs': compile_docs, |
|
165
|
|
|
'sdist': sdist, |
|
166
|
|
|
}, |
|
167
|
|
|
**extra |
|
168
|
|
|
) |
|
169
|
|
|
|