From 62e942d7b81dd3679c1066fbfecea14f51f335e4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Dec 2015 13:25:38 +0530 Subject: [PATCH] Also preserve sip.exe --- setup/installer/windows/install_python.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/setup/installer/windows/install_python.py b/setup/installer/windows/install_python.py index a093efeb25..b69eed02a9 100644 --- a/setup/installer/windows/install_python.py +++ b/setup/installer/windows/install_python.py @@ -10,6 +10,7 @@ import shutil import os import glob import stat +import errno known_extensions = { 'bz2.pyd', @@ -56,7 +57,7 @@ def main(): sp_temp = os.path.join(install_dir, 'site-packages') os.rename(sp_dir, sp_temp) for x in os.listdir(install_dir): - if x != 'site-packages': + if x not in ('Scripts', 'site-packages', 'sip.exe'): path = os.path.join(install_dir, x) (shutil.rmtree if os.path.isdir(path) else os.remove)(path) else: @@ -99,7 +100,11 @@ def main(): shutil.copy2(x, include_dir) # Make the Scripts dir - os.mkdir(os.path.join(install_dir, 'Scripts')) + try: + os.mkdir(os.path.join(install_dir, 'Scripts')) + except EnvironmentError as err: + if err.errno != errno.EEXIST: + raise # Copy the python modules in Lib ignored_dirs = frozenset('pydoc_data test tests lib2to3 ensurepip'.split())