Setting up a Mac as a Rascal development system

Updated October 2012 for the Rascal Beriberi release

I’ve been using the Mac for the past few weeks to put together some new pages for Rascal and it works well. Here’s how I set it up:

You first need a copy of your Rascal directory /var/www. There are a number of ways you can upload this but initially I used scp. In Terminal, starting from your home directory, make a directory called rascal-dev and copy everything into it:

$ mkdir rascal-dev
$ scp -r root@rascalNN.local:/var/www/ rascal-dev/
$ cd rascal-dev

When finished, cd into rascal-dev as shown above. You now need to install the Rascal web framework Flask. There is some good advice on the Flask site where the recommended first step is to install virtualenv. On OS X this requires install_name_tool which is part of Apple’s Xcode developer tools so you need to install these first. With Snow Leopard, after registering as a developer (free), you can login and download Xcode 3.2.6 from the Apple developer site. With Lion the Xcode 4.2.1 installer is available free from the App Store (remember to install it after it has downloaded). You can now install virtualenv and use it to set up a virtual python environment:

$ sudo easy_install virtualenv
$ virtualenv env
New python executable in env/bin/python
Installing setuptools............done.
Installing pip...............done.

Within this environment, anything else you install will only affect this environment. First you activate the environment:

localhost:rascal-dev davids$ . env/bin/activate
(env)localhost:rascal-dev davids$

(note that the shell prompt has changed) and then install Flask:

(env)localhost:rascal-dev davids$ pip install Flask

This installs Flask, the Jinja2 template system and the Werkzeug toolkit.

However, before you can run the Rascal web server, you will need to comment out
the imports of uswgidecorators and pytronics at the start of the file public/

from flask import Flask, render_template, request
# from uwsgidecorators import *
# import pytronics
import os, time

The final step is to start your development Rascal web server:

(env)localhost:rascal-dev davids$ python
* Running on
* Restarting with reloader

If you now open a browser and go to http://localhost:5000/ you should see your Rascal home page.

From now on, whenever you want to do some Rascal development on your Mac, you just open Terminal and type these three lines:

$ cd rascal-dev
$ . env/bin/activate
$ python

Rascal Home Page

Running the Rascal Editor
You can also run the Rascal editor on the Mac. Before doing so, you will need to make it possible for the editor to find the files in the public folder. On Rascal the public folder is at /var/www/. On the Mac there is no directory /var/www/ so an easy solution is to create a symbolic link www in the /var/ directory which points to the rascal-dev folder:

localhost:var davids$ sudo ln -s /Users/davids/rascal-dev/ www

The next step is to install the Flask Login extension:

(env)localhost:rascal-dev davids$ pip install Flask-Login

Finally, you will need to provide a password file to allow you to log in. If you have a Rascal, you can copy its password file from /etc/passwd to the rascal-dev directory. This will allow you to log in to the development editor using the same password as on the Rascal. You need to tell the Rascal editor where to find the password file. Edit the file editor/, commenting out the old location and adding the new one:

# PASSWD_FILE = '/etc/passwd'
PASSWD_FILE = '/var/www/passwd'

Alternatively, if your Rascal hasn’t arrived yet, you can edit the file editor/ and comment out all of the @login_required lines.

Now you can start the editor from another terminal session on port 5001 as follows:

$ cd rascal-dev
$ . env/bin/activate
$ python

At this point you have the public web server running on port on 5000 and the editor on port 5001. Connect to the editor as follows:


The last step is to make the editor aware that the public server is running on port 5000. Edit the file rascal-dev/editor/static/js/editor-resize.js and set the value of DEBUG_ON_MAC to true:

// Debug and resize constants
var DEBUG_ON_MAC = true;

After making this change and reloading the editor, you will be able to create and edit files, view pictures in the editor and open templates by clicking the file name in the location bar above the edit pane.

5 comments on “Setting up a Mac as a Rascal development system

  1. One suggestion about getting the contents of your Rascal /var/www onto your Mac: if you haven’t modified it from its stock condition, it’s probably easiest to just clone the control-freak repository on Github. This repository is the authoritative record of exactly what ends up in /var/www when the Rascal is shipped. Here’s the repo:

  2. Hi,

    Awaiting the availability of a Rascal board I have tried this on an Ubuntu 10.04 LTS machine, but get the following error:
    root@ubuntu:~/rascal-dev# python
    Traceback (most recent call last):
    File “”, line 1, in
    from public import public
    File “/home/linux/rascal-dev/public/”, line 1, in
    from server import *
    File “/home/linux/rascal-dev/public/”, line 2, in
    from uwsgidecorators import *
    File “/opt/ActivePython-2.7/lib/python2.7/”, line 1, in
    import uwsgi
    ImportError: No module named uwsgi

    I perormed the following installtions in advance:
    pip install Flask (the minimal demo application is working fine)
    pip install uwsgi
    I’m using an Activestate python distribution (python 2.7)

    Any suggestions?

  3. Hi Frederik,

    In the file /home/linux/rascal-dev/public/, comment out the line that says from uwsgidecorators import *

    The problem is that because you aren’t running the uWSGI server on your PC, it can’t find the uWSGI library. But you don’t actually need the uWSGI library on a PC– it’s used for things like pin interrupts that won’t work anyway.

    (David, please correct me if I’m wrong about this. You’re more expert than I am in this area.)

    • Hi Frederik

      Brandon is correct, except that the code you need to comment out is at the start of rascal_dev/public/ Note that you also need to comment out “import pytronics” as it it is unlikely you will have pytronics installed on your Linux machine. Here is the start of my Mac version of

      from flask import Flask, render_template, request
      # from uwsgidecorators import *
      # import os, pytronics, time
      import os, time

      public = Flask(__name__)
      public.config['PROPAGATE_EXCEPTIONS'] = True

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 )

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