forked from insomnia-lab/libreant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
118 lines (103 loc) · 3.99 KB
/
setup.py
File metadata and controls
118 lines (103 loc) · 3.99 KB
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
import os
import sys
import msgfmt
from pprint import pprint
from setuptools import setup
from setuptools.command.install_lib import install_lib as _install_lib
from setuptools.command.develop import develop as _develop
from distutils.command.build import build as _build
from distutils.cmd import Command
class compile_translations(Command):
description = 'compile message catalogs to .mo files'
user_options = [('force', 'f', "compile also not updated message catalogs")]
boolean_options = ['force']
def initialize_options(self):
self.force = False
def finalize_options(self):
pass
def run(self):
"""
Compile all message catalogs .mo files into .po files.
Skips not changed file based on source mtime.
"""
# thanks to deluge guys ;)
po_dir = os.path.join(os.path.dirname(__file__), 'webant','translations')
print('Compiling po files from "{}"...'.format(po_dir))
for lang in os.listdir(po_dir):
sys.stdout.write("\tCompiling {}... ".format(lang))
sys.stdout.flush()
curr_lang_path = os.path.join(po_dir,lang)
for path, dirs, filenames in os.walk(curr_lang_path):
for f in filenames:
if f.endswith('.po'):
src = os.path.join(path, f)
dst = os.path.join(path, f[:-3]+".mo")
if not os.path.exists(dst) or self.force:
msgfmt.make(src, dst)
print("ok.")
else:
src_mtime = os.stat(src)[8]
dst_mtime = os.stat(dst)[8]
if src_mtime > dst_mtime:
msgfmt.make(src, dst)
print("ok.")
else:
print("already up to date.")
print('Finished compiling translation files.')
class build(_build):
sub_commands = [('compile_translations', None)] + _build.sub_commands
class install_lib(_install_lib):
def run(self):
self.run_command('compile_translations' )
_install_lib.run(self)
class develop(_develop):
def run(self):
self.run_command('compile_translations' )
_develop.run(self)
def read(fname):
with open(os.path.join(os.path.dirname(__file__), fname)) as buf:
return buf.read()
setup(name='libreant',
version='0.1',
description='{e,}book archive focused on small grass root archives, distributed search, low assumptions',
long_description=read('README.mdwn'),
author='insomnialab',
author_email='insomnialab@hacari.org',
url='https://github.com/insomnia-lab/libreant',
license='AGPL',
packages=['libreantdb', 'webant', 'webant.presets'],
install_requires=[
'gevent',
'elasticsearch',
'flask-bootstrap',
'Flask-Babel',
'flask-appconfig',
'Flask',
'opensearch',
'Fsdb'
],
package_data = {
# If any package contains *.mo include them:
# important! leave all the stars!
'webant': ['translations/*/*/*.mo']
},
include_package_data=True,
tests_require=['nose'],
test_suite='nose.collector',
zip_safe=False,
cmdclass={'build': build,
'install_lib': install_lib,
'develop':develop,
'compile_translations': compile_translations },
entry_points={'console_scripts': [
'webant=webant.webant:main',
'agherant=webant.agherant_standalone:main'
] },
classifiers=[
"Framework :: Flask",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 2",
"Development Status :: 4 - Beta"
]
)