2 # -*- coding: utf-8 -*-
8 from setuptools.command.install_lib import install_lib as _install_lib
9 from distutils.command.build import build as _build
10 from distutils.command.sdist import sdist as _sdist
11 from distutils.cmd import Command
12 from setuptools import setup, find_packages
17 if os.path.exists('VERSION'):
19 version = get_version()
20 with open('VERSION', 'w') as fd:
23 if os.path.exists('VERSION'):
28 if os.path.exists('VERSION'):
29 with open('VERSION', 'r') as v:
31 if os.path.exists('.git'):
32 p = subprocess.Popen(['git', 'describe', '--dirty=.dirty', '--match=v*'],
33 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
34 result = p.communicate()[0]
36 result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
37 if '-' in result: # not a tagged version
38 real_number, commit_count, commit_hash = result.split('-', 2)
39 version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
44 return '0.0.post%s' % len(
45 subprocess.check_output(
46 ['git', 'rev-list', 'HEAD']).splitlines())
50 class compile_translations(Command):
51 description = 'compile message catalogs to MO files via django compilemessages'
54 def initialize_options(self):
57 def finalize_options(self):
62 from django.core.management import call_command
63 for path, dirs, files in os.walk('nonstop'):
64 if 'locale' not in dirs:
67 os.chdir(os.path.realpath(path))
68 call_command('compilemessages')
71 sys.stderr.write('!!! Please install Django to build translations\n')
75 sub_commands = [('compile_translations', None)] + _build.sub_commands
78 class install_lib(_install_lib):
80 self.run_command('compile_translations')
81 _install_lib.run(self)
86 version=get_version(),
87 description='Nonstop',
88 author='Frederic Peters',
89 author_email='fred@radiopanik.org',
90 packages=find_packages(),
91 include_package_data=True,
93 'Development Status :: 4 - Beta',
94 'Environment :: Web Environment',
95 'Framework :: Django',
96 'Intended Audience :: Developers',
97 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
98 'Operating System :: OS Independent',
99 'Programming Language :: Python',
100 'Programming Language :: Python :: 2',
101 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
102 'Topic :: Multimedia :: Sound/Audio',
107 'compile_translations': compile_translations,
108 'install_lib': install_lib,