9 |
9 |
|
10 |
10 |
from setuptools.command.install_lib import install_lib as _install_lib
|
11 |
11 |
from distutils.command.build import build as _build
|
|
12 |
from distutils.errors import CompileError
|
|
13 |
from distutils.spawn import find_executable
|
12 |
14 |
from distutils.command.sdist import sdist
|
13 |
15 |
from distutils.cmd import Command
|
14 |
16 |
from setuptools import setup, find_packages
|
... | ... | |
74 |
76 |
sys.stderr.write('!!! Please install Django >= 1.4 to build translations\n')
|
75 |
77 |
|
76 |
78 |
|
|
79 |
class compile_scss(Command):
|
|
80 |
description = 'compile scss files into css files'
|
|
81 |
user_options = []
|
|
82 |
|
|
83 |
def initialize_options(self):
|
|
84 |
pass
|
|
85 |
|
|
86 |
def finalize_options(self):
|
|
87 |
pass
|
|
88 |
|
|
89 |
def run(self):
|
|
90 |
sass_bin = None
|
|
91 |
for program in ('sassc', 'sass'):
|
|
92 |
sass_bin = find_executable(program)
|
|
93 |
if sass_bin:
|
|
94 |
break
|
|
95 |
if not sass_bin:
|
|
96 |
raise CompileError(
|
|
97 |
'A sass compiler is required but none was found. See sass-lang.com for choices.'
|
|
98 |
)
|
|
99 |
|
|
100 |
for package in self.distribution.packages:
|
|
101 |
for package_path in ['hobo']:
|
|
102 |
for path, dirnames, filenames in os.walk(package_path):
|
|
103 |
for filename in filenames:
|
|
104 |
if not filename.endswith('.scss'):
|
|
105 |
continue
|
|
106 |
if filename.startswith('_'):
|
|
107 |
continue
|
|
108 |
subprocess.check_call(
|
|
109 |
[
|
|
110 |
sass_bin,
|
|
111 |
'%s/%s' % (path, filename),
|
|
112 |
'%s/%s' % (path, filename.replace('.scss', '.css')),
|
|
113 |
]
|
|
114 |
)
|
|
115 |
|
|
116 |
|
77 |
117 |
class build(_build):
|
78 |
|
sub_commands = [('compile_translations', None)] + _build.sub_commands
|
|
118 |
sub_commands = [('compile_translations', None), ('compile_scss', None)] + _build.sub_commands
|
79 |
119 |
|
80 |
120 |
|
81 |
121 |
class install_lib(_install_lib):
|
... | ... | |
117 |
157 |
zip_safe=False,
|
118 |
158 |
cmdclass={
|
119 |
159 |
'build': build,
|
|
160 |
'compile_scss': compile_scss,
|
120 |
161 |
'compile_translations': compile_translations,
|
121 |
162 |
'install_lib': install_lib,
|
122 |
163 |
'sdist': eo_sdist,
|
123 |
|
-
|