From 069832281588a12a1c1c8e50e99e3a8efbaf977d 2011-06-24 19:14:36 From: Min RK Date: 2011-06-24 19:14:36 Subject: [PATCH] wininst post install script updated and requires setuptools In the absence of setuptools, don't create the links that would be broken anyway. --- diff --git a/scripts/ipython_win_post_install.py b/scripts/ipython_win_post_install.py index 4f633fc..1cdae78 100755 --- a/scripts/ipython_win_post_install.py +++ b/scripts/ipython_win_post_install.py @@ -4,6 +4,12 @@ import os, sys, shutil pjoin = os.path.join +# import setuptools if we can +try: + import setuptools +except ImportError: + pass + def mkshortcut(target,description,link_file,*args,**kw): """make a shortcut if it doesn't exist, and register its creation""" @@ -18,6 +24,13 @@ def install(): # Get some system constants prefix = sys.prefix python = pjoin(prefix, 'python.exe') + pythonw = pjoin(prefix, 'pythonw.exe') + have_setuptools = 'setuptools' in sys.modules + + if not have_setuptools: + # This currently doesn't work without setuptools, + # so don't bother making broken links + return # Lookup path to common startmenu ... ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'), 'IPython') @@ -38,20 +51,22 @@ def install(): 'irunner' ] scripts = pjoin(prefix,'scripts') - for program in programs: - raw = pjoin(scripts, program) - bat = raw + '.bat' - py = raw + '.py' - # Create .py versions of the scripts - shutil.copy(raw, py) - # Create .bat files for each of the scripts - bat_file = file(bat,'w') - bat_file.write("@%s %s %%*" % (python, py)) - bat_file.close() - + if not have_setuptools: + # only create .bat files if we don't have setuptools + for program in programs: + raw = pjoin(scripts, program) + bat = raw + '.bat' + py = raw + '.py' + # Create .py versions of the scripts + shutil.copy(raw, py) + # Create .bat files for each of the scripts + bat_file = file(bat,'w') + bat_file.write("@%s %s %%*" % (python, py)) + bat_file.close() + # Now move onto setting the Start Menu up ipybase = pjoin(scripts, 'ipython') - if 'setuptools' in sys.modules: + if have_setuptools: # let setuptools take care of the scripts: ipybase = ipybase + '-script.py' workdir = "%HOMEDRIVE%%HOMEPATH%" @@ -61,21 +76,33 @@ def install(): mkshortcut(python, 'IPython', link, cmd, workdir) link = pjoin(ip_start_menu, 'pysh.lnk') - cmd = '"%s" -p sh' % ipybase + cmd = '"%s" profile=pysh --init' % ipybase mkshortcut(python, 'IPython (command prompt mode)', link, cmd, workdir) - link = pjoin(ip_start_menu, 'scipy.lnk') - cmd = '"%s" -p scipy' % ipybase - mkshortcut(python, 'IPython (scipy profile)', link, cmd, workdir) + link = pjoin(ip_start_menu, 'pylab.lnk') + cmd = '"%s" profile=pylab --init' % ipybase + mkshortcut(python, 'IPython (pylab profile)', link, cmd, workdir) link = pjoin(ip_start_menu, 'ipcontroller.lnk') - cmd = '"%s" -xy' % pjoin(scripts, 'ipcontroller') + cmdbase = pjoin(scripts, 'ipcontroller') + if have_setuptools: + cmdbase += '-script.py' + cmd = '"%s"' % cmdbase mkshortcut(python, 'IPython controller', link, cmd, workdir) link = pjoin(ip_start_menu, 'ipengine.lnk') - cmd = '"%s"' % pjoin(scripts, 'ipengine') + cmdbase = pjoin(scripts, 'ipengine') + if have_setuptools: + cmdbase += '-script.py' + cmd = '"%s"' % cmdbase mkshortcut(python, 'IPython engine', link, cmd, workdir) - + + link = pjoin(ip_start_menu, 'ipythonqt.lnk') + cmdbase = pjoin(scripts, 'ipython-qtconsole') + if have_setuptools: + cmdbase += '-script.pyw' + cmd = '"%s"' % cmdbase + mkshortcut(pythonw, 'IPython Qt Console', link, cmd, workdir) # Create documentation shortcuts ... t = prefix + r'\share\doc\ipython\manual\ipython.pdf' f = ip_start_menu + r'\Manual in PDF.lnk'