from distutils.command.build import build as _build
from distutils.command.sdist import sdist as _sdist
from distutils.cmd import Command
+from distutils.spawn import find_executable
from setuptools import setup, find_packages
call_command('compilemessages')
os.chdir(curdir)
except ImportError:
- sys.stderr.write('!!! Please install Django to build translations\n')
+ sys.stderr.write('!!! Please install Django >= 1.4 to build translations\n')
+
+
+class compile_scss(Command):
+ description = 'compile scss files into css files'
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ sass_bin = None
+ for program in ('sassc', 'sass'):
+ sass_bin = find_executable(program)
+ if sass_bin:
+ break
+ if not sass_bin:
+ raise CompileError(
+ 'A sass compiler is required but none was found. See sass-lang.com for choices.'
+ )
+
+ for path, dirnames, filenames in os.walk('panikdb'):
+ for filename in filenames:
+ if not filename.endswith('.scss'):
+ continue
+ if filename.startswith('_'):
+ continue
+ subprocess.check_call(
+ [
+ sass_bin,
+ '%s/%s' % (path, filename),
+ '%s/%s' % (path, filename.replace('.scss', '.css')),
+ ]
+ )
class build(_build):
- sub_commands = [('compile_translations', None)] + _build.sub_commands
+ sub_commands = [('compile_translations', None), ('compile_scss', None)] + _build.sub_commands
class install_lib(_install_lib):
zip_safe=False,
cmdclass={
'build': build,
+ 'compile_scss': compile_scss,
'compile_translations': compile_translations,
'install_lib': install_lib,
'sdist': sdist,