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
9 from distutils.errors import CompileError
10 from distutils.spawn import find_executable
12 from setuptools import find_packages, setup
13 from setuptools.command.install_lib import install_lib as _install_lib
18 if os.path.exists('VERSION'):
20 version = get_version()
21 with open('VERSION', 'w') as fd:
24 if os.path.exists('VERSION'):
29 if os.path.exists('VERSION'):
30 with open('VERSION') as v:
32 if os.path.exists('.git'):
34 ['git', 'describe', '--dirty=.dirty', '--match=v*'],
35 stdout=subprocess.PIPE,
36 stderr=subprocess.PIPE,
38 result = p.communicate()[0]
40 result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
41 if '-' in result: # not a tagged version
42 real_number, commit_count, commit_hash = result.split('-', 2)
43 version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
48 return '0.0.post%s' % len(subprocess.check_output(['git', 'rev-list', 'HEAD']).splitlines())
52 class compile_translations(Command):
53 description = 'compile message catalogs to MO files via django compilemessages'
56 def initialize_options(self):
59 def finalize_options(self):
64 from django.core.management import call_command
66 for path, dirs, files in os.walk('panikweb_esperanzah'):
67 if 'locale' not in dirs:
70 os.chdir(os.path.realpath(path))
71 call_command('compilemessages')
74 sys.stderr.write('!!! Please install Django to build translations\n')
77 class compile_scss(Command):
78 description = 'compile scss files into css files'
81 def initialize_options(self):
84 def finalize_options(self):
89 for program in ('sassc', 'sass'):
90 sass_bin = find_executable(program)
95 'A sass compiler is required but none was found. See sass-lang.com for choices.'
98 for path, dirnames, filenames in os.walk('panikweb_esperanzah'):
99 for filename in filenames:
100 if not filename.endswith('.scss'):
102 if filename.startswith('_'):
104 subprocess.check_call(
107 '%s/%s' % (path, filename),
108 '%s/%s' % (path, filename.replace('.scss', '.css')),
114 sub_commands = [('compile_translations', None), ('compile_scss', None)] + _build.sub_commands
117 class install_lib(_install_lib):
119 self.run_command('compile_translations')
120 _install_lib.run(self)
124 name='panikweb_esperanzah',
125 version=get_version(),
126 description='Panikweb extension/theme for Radio Esperanzah',
127 author='Frederic Peters',
128 author_email='fpeters@0d.be',
129 url='https://radio.esperanzah.be',
130 packages=find_packages(),
131 include_package_data=True,
133 'Development Status :: 3 - Alpha',
134 'Environment :: Web Environment',
135 'Framework :: Django',
136 'Intended Audience :: Developers',
137 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
138 'Operating System :: OS Independent',
139 'Programming Language :: Python',
140 'Programming Language :: Python :: 3',
141 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
146 'compile_scss': compile_scss,
147 'compile_translations': compile_translations,
148 'install_lib': install_lib,