1 #! /usr/bin/env python3
6 from distutils.cmd import Command
7 from distutils.command.build import build as _build
8 from distutils.command.sdist import sdist as _sdist
10 from setuptools import find_packages, setup
11 from setuptools.command.install_lib import install_lib as _install_lib
16 if os.path.exists('VERSION'):
18 version = get_version()
19 with open('VERSION', 'w') as fd:
22 if os.path.exists('VERSION'):
27 if os.path.exists('VERSION'):
28 with open('VERSION') as v:
30 if os.path.exists('.git'):
32 ['git', 'describe', '--dirty=.dirty', '--match=v*'],
33 stdout=subprocess.PIPE,
34 stderr=subprocess.PIPE,
36 result = p.communicate()[0]
38 result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
39 if '-' in result: # not a tagged version
40 real_number, commit_count, commit_hash = result.split('-', 2)
41 version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
46 return '0.0.post%s' % len(subprocess.check_output(['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
64 for path, dirs, files in os.walk('panikombo'):
65 if 'locale' not in dirs:
68 os.chdir(os.path.realpath(path))
69 call_command('compilemessages')
72 sys.stderr.write('!!! Please install Django to build translations\n')
76 sub_commands = [('compile_translations', None)] + _build.sub_commands
79 class install_lib(_install_lib):
81 self.run_command('compile_translations')
82 _install_lib.run(self)
87 version=get_version(),
88 description='Combo extensions for Radio Panik',
89 author='Frederic Peters',
90 author_email='fred@radiopanik.org',
91 packages=find_packages(),
92 include_package_data=True,
94 'Development Status :: 4 - Beta',
95 'Environment :: Web Environment',
96 'Framework :: Django',
97 'Intended Audience :: Developers',
98 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
99 'Operating System :: OS Independent',
100 'Programming Language :: Python',
101 'Programming Language :: Python :: 2',
102 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
103 'Topic :: Multimedia :: Sound/Audio',
108 'compile_translations': compile_translations,
109 'install_lib': install_lib,