5 |
5 |
import sys
|
6 |
6 |
from distutils.cmd import Command
|
7 |
7 |
from distutils.command.build import build as _build
|
|
8 |
from distutils.errors import CompileError
|
|
9 |
from distutils.spawn import find_executable
|
8 |
10 |
|
9 |
11 |
from setuptools import find_packages, setup
|
10 |
12 |
from setuptools.command.install_lib import install_lib as _install_lib
|
... | ... | |
77 |
79 |
os.chdir(curdir)
|
78 |
80 |
|
79 |
81 |
|
|
82 |
class compile_scss(Command):
|
|
83 |
description = 'compile scss files into css files'
|
|
84 |
user_options = []
|
|
85 |
|
|
86 |
def initialize_options(self):
|
|
87 |
pass
|
|
88 |
|
|
89 |
def finalize_options(self):
|
|
90 |
pass
|
|
91 |
|
|
92 |
def run(self):
|
|
93 |
sass_bin = None
|
|
94 |
for program in ('sassc', 'sass'):
|
|
95 |
sass_bin = find_executable(program)
|
|
96 |
if sass_bin:
|
|
97 |
break
|
|
98 |
if not sass_bin:
|
|
99 |
raise CompileError(
|
|
100 |
'A sass compiler is required but none was found. See sass-lang.com for choices.'
|
|
101 |
)
|
|
102 |
|
|
103 |
for path, dirnames, filenames in os.walk('passerelle'):
|
|
104 |
for filename in filenames:
|
|
105 |
if not filename.endswith('.scss'):
|
|
106 |
continue
|
|
107 |
if filename.startswith('_'):
|
|
108 |
continue
|
|
109 |
subprocess.check_call(
|
|
110 |
[
|
|
111 |
sass_bin,
|
|
112 |
'%s/%s' % (path, filename),
|
|
113 |
'%s/%s' % (path, filename.replace('.scss', '.css')),
|
|
114 |
]
|
|
115 |
)
|
|
116 |
|
|
117 |
|
80 |
118 |
class build(_build):
|
81 |
|
sub_commands = [('compile_translations', None)] + _build.sub_commands
|
|
119 |
sub_commands = [('compile_translations', None), ('compile_scss', None)] + _build.sub_commands
|
82 |
120 |
|
83 |
121 |
|
84 |
122 |
class install_lib(_install_lib):
|
... | ... | |
128 |
166 |
],
|
129 |
167 |
cmdclass={
|
130 |
168 |
'build': build,
|
|
169 |
'compile_scss': compile_scss,
|
131 |
170 |
'compile_translations': compile_translations,
|
132 |
171 |
'install_lib': install_lib,
|
133 |
172 |
'sdist': eo_sdist,
|
134 |
|
-
|