From 0033a648813f3066a718ba2b40981b8b0e8e3439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 26 Nov 2017 17:14:49 +0100 Subject: [PATCH 1/3] build: switch stylesheet to scss (#20283) --- .../manager/static/css/{style.css => style.scss} | 0 debian/control | 2 +- setup.py | 36 +++++++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) rename chrono/manager/static/css/{style.css => style.scss} (100%) diff --git a/chrono/manager/static/css/style.css b/chrono/manager/static/css/style.scss similarity index 100% rename from chrono/manager/static/css/style.css rename to chrono/manager/static/css/style.scss diff --git a/debian/control b/debian/control index 166cda9..4fee519 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: chrono Maintainer: Frederic Peters Section: python Priority: optional -Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), python-django, debhelper (>= 7), dh-systemd +Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), python-django, debhelper (>= 7), dh-systemd, ruby-sass Standards-Version: 3.9.6 X-Python-Version: >= 2.7 diff --git a/setup.py b/setup.py index e802109..987d116 100644 --- a/setup.py +++ b/setup.py @@ -11,6 +11,7 @@ from setuptools.command.install_lib import install_lib as _install_lib from distutils.command.build import build as _build from distutils.command.sdist import sdist from distutils.cmd import Command +from distutils.spawn import find_executable from setuptools import setup, find_packages class eo_sdist(sdist): @@ -70,8 +71,40 @@ class compile_translations(Command): 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 ('sass', 'sassc'): + 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 package in self.distribution.packages: + for package_path in __import__(package).__path__: + for path, dirnames, filenames in os.walk(package_path): + 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): @@ -111,6 +144,7 @@ setup( zip_safe=False, cmdclass={ 'build': build, + 'compile_scss': compile_scss, 'compile_translations': compile_translations, 'install_lib': install_lib, 'sdist': eo_sdist, -- 2.15.0