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
32 def install_nano(install_directory):
33 """Download and install the nano text editor"""
34 url = "http://www.nano-editor.org/dist/v2.2/NT/nano-2.2.6.zip"
36 nano_zip_content = _BytesIO(r.content)
37 nano_zip = zipfile.ZipFile(nano_zip_content)
38 nano_files = ['nano.exe', 'cygwin1.dll', 'cygintl-8.dll',
39 'cygiconv-2.dll', 'cyggcc_s-1.dll']
40 for file_name in nano_files:
41 nano_zip.extract(file_name, install_directory)
43 def create_ipython_entry_point(python_scripts_directory):
44 """Creates a terminal-based IPython entry point for msysgit"""
45 output_file = open(python_scripts_directory + 'ipython', 'w')
46 file_contents = """#!/usr/bin/env python
48 from IPython.frontend.html.notebook.notebookapp import launch_new_instance as launch_notebook
49 from IPython.frontend.terminal.ipapp import launch_new_instance as launch_ipython
52 if len(sys.argv) > 1 and sys.argv[1] == 'notebook':
53 sys.exit(launch_notebook())
55 sys.exit(launch_ipython())
57 if __name__ == '__main__':
61 output_file.write(file_contents)
63 def create_nosetests_entry_point(python_scripts_directory):
64 """Creates a terminal-based nosetests entry point for msysgit"""
65 output_file = open(python_scripts_directory + 'nosetests', 'w')
66 file_contents = """#!/usr/bin/env/ python
70 if __name__ == '__main__':
71 sys.exit(nose.core.main())
73 output_file.write(file_contents)
76 python_scripts_directory = "C:\\Anaconda\\Scripts\\"
77 #python_scripts_directory = "./scripts/"
78 create_ipython_entry_point(python_scripts_directory)
79 create_nosetests_entry_point(python_scripts_directory)
80 install_nano(python_scripts_directory)
83 if __name__ == '__main__':