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.

wget http://prdownloads.sourceforge.net/scons/scons-1.2.0.tar.gz
tar -xzvf scons-1.2.0.tar.gz
cd scons-1.2.0
sudo python setup.py 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/Main.py”, line 826, in _main

Install CSSTidy


wget http://downloads.sourceforge.net/csstidy/csstidy-source-1.4.zip?modtime=1184828155&big_mirror=0
unzip csstidy-source-1.4.zip
scons
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.

11 responses to this post.

  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.

    Reply

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

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

    Reply

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

    Reply

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

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

      Reply

  4. As Bryan pointed out on Stack Overflow, the third step under Install CSSTidy – “cd csstidy” – should be removed. Otherwise you keep getting the error everyone is having above.

    http://stackoverflow.com/questions/1223647/csstidy-is-driving-me-crazy

    Thanks to everyone involved! This was very helpful.

    Reply

  5. +1 to Matt/Bryan

    Don’t “cd csstidy”

    Reply

  6. 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.

    Kurt

    Reply

  7. [...] Installing CSSTidy and Scons on OS X or Linux « ThingsILearned [...]

    Reply

  8. Posted by felix on March 29, 2011 at 2:51 pm

    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.

    Reply

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

    Reply

  10. Posted by Colin Viebrock on November 18, 2011 at 11:32 am

    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?

    Reply

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Follow

Get every new post delivered to your Inbox.