sassutils.distutilssetuptools/distutils integration

This module provides extensions (and some magical monkey-patches, sorry) of the standard distutils and setuptools (now it’s named Distribute) for libsass.

To use this, add libsass into setup_requires (not install_requires) option of the setup.py script:

from setuptools import setup

setup(
    # ...,
    setup_requires=['libsass >= 0.6.0']
)

It will adds build_sass command to the setup.py script:

$ python setup.py build_sass

This commands builds Sass/SCSS files to compiled CSS files of the project and makes the package archive (made by sdist, bdist, and so on) to include these compiled CSS files.

To set the directory of Sass/SCSS source files and the directory to store compiled CSS files, specify sass_manifests option:

from setuptools import find_packages, setup

setup(
    name='YourPackage',
    packages=find_packages(),
    sass_manifests={
        'your.webapp': ('static/sass', 'static/css')
    },
    setup_requires=['libsass >= 0.6.0']
)

The option should be a mapping of package names to pairs of paths, e.g.:

{
    'package': ('static/sass', 'static/css'),
    'package.name': ('static/scss', 'static')
}

The option can also be a mapping of package names to manifest dictionaries:

{
    'package': {
        'sass_path': 'static/sass',
        'css_path': 'static/css',
        'strip_extension': True,
    },
}

New in version 0.15.0: Added strip_extension so a.scss is compiled to a.css instead of a.scss.css. This option will default to True in the future.

New in version 0.6.0: Added --output-style/-s option to build_sass command.

class sassutils.distutils.build_sass(dist, **kw)

Builds Sass/SCSS files to CSS files.

finalize_options()

Set final values for all the options that this command supports. This is always called as late as possible, ie. after any option assignments from the command-line or from other commands have been done. Thus, this is the place to code option dependencies: if ‘foo’ depends on ‘bar’, then it is safe to set ‘foo’ from ‘bar’ as long as ‘foo’ still has the same value it was assigned in ‘initialize_options()’.

This method must be implemented by all command classes.

get_package_dir(package)

Returns the directory, relative to the top of the source distribution, where package package should be found (at least according to the package_dir option, if any).

Copied from distutils.command.build_py.get_package_dir() method.

initialize_options()

Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, ‘initialize_options()’ implementations are just a bunch of “self.foo = None” assignments.

This method must be implemented by all command classes.

run()

A command’s raison d’etre: carry out the action it exists to perform, controlled by the options initialized in ‘initialize_options()’, customized by other commands, the setup script, the command-line, and config files, and finalized in ‘finalize_options()’. All terminal output and filesystem interaction should be done by ‘run()’.

This method must be implemented by all command classes.

sassutils.distutils.validate_manifests(dist, attr, value)

Verifies that value is an expected mapping of package to sassutils.builder.Manifest.