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