From 906dd4305ff4230a80ce74fec5f78c8e8a1c5384 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Dec 2015 13:20:21 +0530 Subject: [PATCH] Move creation of pycygrun into the install script --- setup/installer/windows/install_python.py | 11 +++++++++++ setup/installer/windows/notes2.rst | 16 +--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/setup/installer/windows/install_python.py b/setup/installer/windows/install_python.py index 2140fd1c56..a093efeb25 100644 --- a/setup/installer/windows/install_python.py +++ b/setup/installer/windows/install_python.py @@ -9,6 +9,7 @@ import re import shutil import os import glob +import stat known_extensions = { 'bz2.pyd', @@ -128,6 +129,16 @@ def main(): if num != 1: raise SystemExit('Failed to patch mimetypes.py') f.write(raw) + pycgrun = os.path.join(install_dir, 'pycygrun') + with open(pycgrun, 'wb') as f: + f.write(b'''\ +#!/bin/zsh +SCRIPT=$(readlink -f $0) +SCRIPTPATH=`dirname $SCRIPT` +PYSCRIPT=`cygpath -w $1` +exec $SCRIPTPATH/python.exe $PYSCRIPT ${@:2} +''') + os.chmod(pycgrun, stat.S_IRWXU) print('python installed to:', install_dir) diff --git a/setup/installer/windows/notes2.rst b/setup/installer/windows/notes2.rst index 04fa92c777..4655bafd36 100644 --- a/setup/installer/windows/notes2.rst +++ b/setup/installer/windows/notes2.rst @@ -39,7 +39,7 @@ Run:: Create a file ~/bin/winenv with the following:: cat << ' EOF' | sed -e 's/^ *//' > ~/bin/winenv - #!pyrun + #!pycygrun import os, subprocess, sys env = os.environ.copy() # Ensure windows based exes are used in preference to cygwin ones @@ -144,20 +144,6 @@ For 32-bit:: Make sure ~/sw/private/python is in your PATH -Run:: - - cat << ' EOF' | sed -e 's/^ *//' > ~/sw/private/python/pyrun - #!/bin/zsh - SCRIPT=$(readlink -f $0) - SCRIPTPATH=`dirname $SCRIPT` - PYSCRIPT=`cygpath -w $1` - exec $SCRIPTPATH/python.exe $PYSCRIPT ${@:2} - EOF - chmod +x ~/sw/private/python/pyrun - -This creates a pyrun executable that can be used as a shebang in python scripts -you intend to run directly via cygwin. - Basic dependencies --------------------