1 #! /usr/bin/env python3
7 from setuptools.command.install_lib import install_lib as _install_lib
8 from distutils.command.build import build as _build
9 from distutils.command.sdist import sdist as _sdist
10 from distutils.cmd import Command
11 from distutils.spawn import find_executable
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('panikdb'):
64 if 'locale' not in dirs:
67 os.chdir(os.path.realpath(path))
68 call_command('compilemessages')
71 sys.stderr.write('!!! Please install Django >= 1.4 to build translations\n')
74 class compile_scss(Command):
75 description = 'compile scss files into css files'
78 def initialize_options(self):
81 def finalize_options(self):
86 for program in ('sassc', 'sass'):
87 sass_bin = find_executable(program)
92 'A sass compiler is required but none was found. See sass-lang.com for choices.'
95 for path, dirnames, filenames in os.walk('panikdb'):
96 for filename in filenames:
97 if not filename.endswith('.scss'):
99 if filename.startswith('_'):
101 subprocess.check_call(
104 '%s/%s' % (path, filename),
105 '%s/%s' % (path, filename.replace('.scss', '.css')),
111 sub_commands = [('compile_translations', None), ('compile_scss', None)] + _build.sub_commands
114 class install_lib(_install_lib):
116 self.run_command('compile_translations')
117 _install_lib.run(self)
122 version=get_version(),
123 description='Radio Panik Database Management',
124 author='Frederic Peters',
125 author_email='fred@radiopanik.org',
126 packages=find_packages(),
127 url='https://www.radiopanik.org',
128 include_package_data=True,
129 scripts=('manage.py',),
131 'Development Status :: 4 - Beta',
132 'Environment :: Web Environment',
133 'Framework :: Django',
134 'Intended Audience :: Developers',
135 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
136 'Operating System :: OS Independent',
137 'Programming Language :: Python',
138 'Programming Language :: Python :: 3',
139 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
140 'Topic :: Multimedia :: Sound/Audio',
145 'compile_scss': compile_scss,
146 'compile_translations': compile_translations,
147 'install_lib': install_lib,