trac-bootstrap-script /

Full commit
# The code to bootstrap Trac with environment created in .trac
# subdir in current directory.
# Placed into public domain by anatoly techtonik

import os
import sys
import subprocess

DEVPATH = os.path.dirname(os.path.abspath(__file__))
ENVPATH = os.path.join(DEVPATH, '.trac')
# path to download dependency modules
LIBPATH = os.path.join(DEVPATH, '.pylibs')

# module checkout URLs

print("Executing Trac from source checkout (using .trac/ environment)")

sys.path.insert(0, LIBPATH)
print("01. Patched sys.path with %s" % LIBPATH)
sys.path.insert(0, DEVPATH)
print("01. Patched sys.path with %s" % DEVPATH)

def get_module(url, path):
  print("... checking out module from SVN")
  if not os.path.exists(path):
    print "... creating %s" % path
  cmd = "svn co %s %s" % (url, path)
  print("... executing: %s" % cmd)
  retcode =, shell=True)
  if retcode != 0:
    sys.exit("Error while executing SVN. Aborting")

print("02. Check Genshi")
  import imp
except ImportError:
  get_module(GENSHI, os.path.join(LIBPATH, 'genshi'))
import genshi
print("... imported Genshi %s" % genshi.__version__)

if not os.path.exists(ENVPATH):
  print("03. Creating .trac/ environment")
  import trac.admin.console[])  
  print("03. .trac/ environment already exists - exiting")