SciPy Central
JavaScript Python CSS HTML
Pull request Compare This branch is 2 commits ahead of scipy:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Scipy Central

This is the web app serving, a source code snippet sharing site.

Development setup

Quick start

To set up a development environment quickly, you can install the Virtualenv package ( and then run:


This will create a virtualenv under deploy/env and download, use easy_install to get correct versions of prerequisites from the Internet, and finally run the initial database setup.


The minimal set of required Python packages and package versions is listed in requirements.txt. See for the package downloads.

You can also install the required packages automatically with the command:

pip install -r requirements.txt --use-mirrors

or, on Windows, by running:

easy_install "Django >=1.4,<1.5" ( of the lines...)

For searching, you can optionally use Xapian instead of Whoosh:


  • Clone the SciPy Central code repository:

    git clone

  • Ensure the following Django settings are in your file:

    • CSRF_FAILURE_VIEW = 'scipy_central.pages.views.csrf_failure'
    • ROOT_URLCONF = 'deploy.urls'
    • INSTALLED_APPS contains these apps:
      • 'django.contrib.auth'
      • 'django.contrib.contenttypes'
      • 'django.contrib.sessions'
      • 'django.contrib.sites'
      • 'django.contrib.messages'
      • 'django.contrib.staticfiles'
      • 'django.contrib.admin'
      • 'django.contrib.admindocs'
      • 'django.contrib.humanize'
      • 'haystack'
      • 'registration'
      • 'south'
      • 'widget_tweaks'
      • 'scipy_central.filestorage'
      • 'scipy_central.pages'
      • 'scipy_central.person'
      • 'scipy_central.submission'
      • 'scipy_central.tagging'
      • 'scipy_central.screenshot'
      • 'scipy_central.pagehit'
    • AUTH_PROFILE_MODULE = 'person.UserProfile'
    • LOGIN_URL = '/user/login/'
    • SPC = { ... }: see which key-value pairs are required by examing the code in the file that is part of the SciPy Central code repository.
    • JQUERY_URL = '...'
    • JQUERYUI_URL = '...'
    • JQUERYUI_CSS = '...'
    • LOGGING = {...}: you need a logger called scipycentral, see more information at and also see the file that is part of the SciPy Central code repository.
  • To make changes in design

    • Require less>=1.4.1 for compiling LESS files to css
    • Follow readme.rst in ./deploy/media/less/ for more information
  • Ensure purge extension is turned on in Mercurial settings (.hgrc)


./ syncdb
./ migrate            # to run the ``south`` db migrations
./ loaddata base      # to load licenses, tags and other basic data
./ loaddata sample    # to load a few sample submissions
./ rebuild_index      # to rebuild the Haystack search index
./ update_index

Backup and restore

There are 4 components to backup:

  1. Database: use deploy/
  2. Repositories: use rsync and mirror SPC['storage_dir'] directory that you set in
  3. Raw image files: rsync the SPC['raw_image_dir']
  4. Resized images: rsync the SPC['resized_image_dir']

To restore:

  1. Delete your existing database.
  2. Run: ./ syncdb to create the empty tables in the database.
  3. ./ migrate to run the south db migrations
  4. ./ reset contenttypes to remove the contenttypes objects created by syncdb, which will inevitibly clash with those restored from the database dump (in the next step). See
  5. ./ loaddata backup-YYYY-MM-DD-HH-MM-SS.json which restores the json database dump created by in step 1 of the backup procedure.
  6. Do a full mirror of the rsynced repositories to your new SPC['storage_dir'] location. This storage contains hidden directories (.hg or .git directories).
  7. Similarly, restore the mirror of the resized images (the raw images may optionally be restored).


Code from other BSD-licensed applications has been used in this project, and attributed at the point of use. In summary though, we have used code from:

The jQuery Forms extensions is MIT licensed (compatible with BSD); more information at

The Rss Feed icon is taken from Wikipedia and its licensed under GNU GPL v2, GNU LGPL v2.1, Mozilla Public License v1.1 and is described at