Installing CSSTidy and Scons on OS X or Linux

I’m setting up django-compress, and incredibly helpful django tool for compressing media files.  By default it requires the installation of CSSTidy which was not as smooth of a task as most.  Here are my notes.

Installing Scons

To install CSSTidy you have to have Scons in order to install it.  Scons is similar to Make but uses python and probably has a ton of other differences as well.  The following will install scons.

tar -xzvf scons-1.2.0.tar.gz
cd scons-1.2.0
sudo python install --standard-lib

I took me a short while to discover the need to use the –standard-lib flag.  If you do not scons is not installed in the python path and you will get the following error when trying to install csstidy

scons: *** No SConstruct file found.
File “/usr/local/lib/scons-1.2.0/SCons/Script/”, line 826, in _main

Install CSSTidy

sudo cp release/csstidy/csstidy /usr/local/bin/

Note that the last command assumes /usr/local/bin is in your $PATH.  Change it if you would like to place it in another place.

  1. Thanks for sharing, this was very helpful.

    I did run into a little issue installing csstidy. When I ran `scons` in the unzipped csstidy dir, I got this error:

    Traceback (most recent call last):
      File "/usr/local/bin/scons", line 162, in 
        import SCons.Script
    ImportError: No module named SCons.Script

    I went back to the untarred scons folder and installed it again, this time ommitting the –standard-lib arg, which worked fine. Then I went back to the csstidy dir and re-ran scons, and csstidy installed without issue.

  2. Dave said:

    Hi Dave.
    (For others who land here….)
    Just a little correction to your OSX SCons install instruction. It should be:
    sudo python install –standard-lib
    (2 dashes, not 1, before standard-lib)

    This instruction is in the README.txt file.
    ciao, D.

  3. Dave said:

    Oh I see the problem. Your blog site seems to remove the second ‘-‘ before the “standard-lib”

    • Thanks for leaving the note. WordPress sometimes takes extra liberties with the text :(.

      I’ve updated to wrap the lines in [sourcecode] tags, so it won’t be an issue anymore. Thanks again.

  4. Keith said:

    +1 to Matt/Bryan

    Don’t “cd csstidy”

  5. Thanks for the instructions.

    You should remove the cd csstidy instruction – you have to run scons from the directory that contains SConstruct, and following your directions, SConstruct is in ../csstidy , not in ./csstidy.

    Hopefully that’ll be helpful to someone else who’s trying this out.


  6. felix said:

    at least for me SCons failed to install itself correctly as shown above.

    it put the folder scons-1.2.0-py2.6.egg into site_packages

    but then inside that is a useless folder scons-1.2.0

    and the actual SCons folder/module is below that so python cannot even see it. its not on the path at all ! its one folder too deep

    I rearranged the contents of the egg and now it works.

  7. That was pretty nice solution. I had same problem where I got Scons via easy_install on my OSX Python 2.6

  8. Colin Viebrock said:

    Trying this under Lion. I got scons installed fine, but when I go to build CSSTidy, I get:

    cmv$ scons
    scons: Reading SConscript files …
    **** Compiling in release mode…

    scons: warning: The env.Copy() method is deprecated; use the env.Clone() method instead.
    File “/Users/cmv/Downloads/csstidy-source-1.4/csstidy/SConscript”, line 7, in

    scons: warning: BuildDir() and the build_dir keyword have been deprecated;
    use VariantDir() and the variant_dir keyword instead.
    File “/Users/cmv/Downloads/csstidy-source-1.4/csstidy/SConscript”, line 21, in
    scons: done reading SConscript files.
    scons: Building targets …
    o release/csstidy/background.o -c -O2 csstidy/background.cpp
    sh: o: command not found

    It seems like it’s trying to use “o” for my compiler. Any ideas?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s