def setup(self):
super(PyScss, self).setup()
import scss
self.scss = scss
if self.style:
try:
from packaging.version import Version
except ImportError:
from distutils.version import LooseVersion as Version
assert Version(scss.__version__) >= Version('1.2.0'), \
'PYSCSS_STYLE only supported in pyScss>=1.2.0'
# Initialize various settings:
# Why are these module-level, not instance-level ?!
# TODO: It appears that in the current dev version, the
# settings can finally passed to a constructor. We'll need
# to support this.
# Only the dev version appears to support a list
if self.load_paths:
scss.config.LOAD_PATHS = ','.join(self.load_paths)
# These are needed for various helpers (working with images
# etc.). Similar to the compass filter, we require the user
# to specify such paths relative to the media directory.
try:
scss.config.STATIC_ROOT = self.static_root or self.ctx.directory
scss.config.STATIC_URL = self.static_url or self.ctx.url
except EnvironmentError:
raise EnvironmentError('Because Environment.url and/or '
'Environment.directory are not set, you need to '
'provide values for the PYSCSS_STATIC_URL and/or '
'PYSCSS_STATIC_ROOT settings.')
# This directory PyScss will use when generating new files,
# like a spritemap. Maybe we should REQUIRE this to be set.
scss.config.ASSETS_ROOT = self.assets_root or scss.config.STATIC_ROOT
scss.config.ASSETS_URL = self.assets_url or scss.config.STATIC_URL
评论列表
文章目录