3 """Software Carpentry Windows Installer
5 Helps mimic a *nix environment on Windows with as little work as possible.
8 * Provides standard ipython operation for msysgit
9 * Provides standard nosetests behavior for msysgit
10 * Installs nano and makes it accessible from msysgit
14 1. Install Anaconda CE Python distribution
15 http://continuum.io/anacondace.html
17 http://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git
18 3. Run swc_windows_installer.py
19 You should be able to simply double click the file in Windows
23 from io import BytesIO as _BytesIO
24 except ImportError: # Python 2
25 from StringIO import StringIO as _BytesIO
33 def install_nano(python_scripts_directory):
34 """Download and install the nano text editor"""
35 url = "http://www.nano-editor.org/dist/v2.2/NT/nano-2.2.6.zip"
37 nano_zip_content = _BytesIO(r.content)
38 nano_zip = zipfile.ZipFile(nano_zip_content)
39 nano_files = ['nano.exe', 'cygwin1.dll', 'cygintl-8.dll',
40 'cygiconv-2.dll', 'cyggcc_s-1.dll']
41 for file_name in nano_files:
42 nano_zip.extract(file_name, '.')
43 shutil.move(file_name, python_scripts_directory)
45 def create_ipython_entry_point(python_scripts_directory):
46 """Creates a terminal-based IPython entry point for msysgit"""
47 output_file = open(python_scripts_directory + 'ipython', 'w')
48 file_contents = """#!/usr/bin/env python
50 from IPython.frontend.html.notebook.notebookapp import launch_new_instance as launch_notebook
51 from IPython.frontend.terminal.ipapp import launch_new_instance as launch_ipython
54 if len(sys.argv) > 1 and sys.argv[1] == 'notebook':
55 sys.exit(launch_notebook())
57 sys.exit(launch_ipython())
59 if __name__ == '__main__':
63 output_file.write(file_contents)
65 def create_nosetests_entry_point(python_scripts_directory):
66 """Creates a terminal-based nosetests entry point for msysgit"""
67 output_file = open(python_scripts_directory + 'nosetests', 'w')
68 file_contents = """#!/usr/bin/env/ python
72 if __name__ == '__main__':
73 sys.exit(nose.core.main())
75 output_file.write(file_contents)
78 python_scripts_directory = "C:\\Anaconda\\Scripts\\"
79 #python_scripts_directory = "./scripts/"
80 create_ipython_entry_point(python_scripts_directory)
81 create_nosetests_entry_point(python_scripts_directory)
82 install_nano(python_scripts_directory)
85 if __name__ == '__main__':