import virtualenv, textwrap recipe = textwrap.dedent(''' import os, subprocess, sys win32 = """ We require Python 2.5.1. You can download it here: http://www.python.org/ftp/python/2.5.1/python-2.5.1.msi """ darwin = """ We require Python 2.5.1. You can download a Universal build here: http://www.python.org/ftp/python/2.5.1/python-2.5.1-macosx.dmg """ other = """ We require Python 2.5.1. This version of Python is often available in your operating system's native package format (via apt-get or yum, for instance). You can also easily build Python from source on Unix-like systems. Here is the source download link for Python: http://www.python.org/ftp/python/2.5.1/Python-2.5.1.tar.bz2 """ def extend_parser(optparse_parser): pass def set_bin_dir(home_dir): global bin_dir, easy_install if sys.platform == 'win32': bin_dir = join(home_dir, 'Scripts') # We have to run the script explicitly because easy_install sets its exe to require admin # privs on Vista. We don't actually need such privs, so we avoid the elevation. easy_install = 'easy_install-script.py' else: bin_dir = join(home_dir, 'bin') easy_install = 'easy_install' def run_bin_executable(prog, *args): cmd = [join(bin_dir, prog)] cmd.extend(args) subprocess.call(cmd) def run_py_script(*args): run_bin_executable('python', *args) def inst_package(package, *args): run_py_script(join(bin_dir, easy_install), package, *args) def check_python(): if sys.version_info < (2,5): if sys.platform == "darwin": print darwin elif sys.platform == "win32": print win32 else: print other return False else: return True def after_install(options, home_dir): if not check_python(): sys.exit() set_bin_dir(home_dir) if sys.platform == "win32": inst_package('pywin32') inst_package('--editable', '-b', home_dir, 'chardb==dev') proj_root = join(home_dir, 'chardb', 'chardb') os.chdir(proj_root) run_py_script('setup.py', 'develop') run_py_script('setup.py', 'nuke') ''') open('devel.py', 'w').write(virtualenv.create_bootstrap_script(recipe))