I've tried to implement Compass compiling during setuptools' build, but the following code runs compilation during explicit build command and doesn't runs during install.
#!/usr/bin/env python
import os
import setuptools
from distutils.command.build import build
SETUP_DIR = os.path.dirname(os.path.abspath(__file__))
class BuildCSS(setuptools.Command):
    description = 'build CSS from SCSS'
    user_options = []
    def initialize_options(self):
        pass
    def run(self):
        os.chdir(os.path.join(SETUP_DIR, 'django_project_dir', 'compass_project_dir'))
        import platform
        if 'Windows' == platform.system():
            command = 'compass.bat compile'
        else:
            command = 'compass compile'
        import subprocess
        try:
            subprocess.check_call(command.split())
        except (subprocess.CalledProcessError, OSError):
            print 'ERROR: problems with compiling Sass. Is Compass installed?'
            raise SystemExit
        os.chdir(SETUP_DIR)
    def finalize_options(self):
        pass
class Build(build):
    sub_commands = build.sub_commands + [('build_css', None)]
setuptools.setup(
    # Custom attrs here.
    cmdclass={
        'build': Build,
        'build_css': BuildCSS,
    },
)
Any custom instructions at Build.run (e.g. some printing) doesn't apply during install too, but dist instance contains in commands attribute only my build command implementation instances. Incredible! But I think the trouble is in complex relations between setuptools and distutils. Does anybody knows how to make custom building run during install on Python 2.7?
Update: Found that install definitely doesn't calls build command, but it calls bdist_egg which runs build_ext. Seems like I should implement "Compass" build extension.