Title: [136441] trunk/Tools
Revision
136441
Author
dpra...@chromium.org
Date
2012-12-03 14:49:54 -0800 (Mon, 03 Dec 2012)

Log Message

webkitpy: autoinstaller is failing on windows
https://bugs.webkit.org/show_bug.cgi?id=103699

Reviewed by Tony Chang.

Attempt to fix the python autoinstaller to work for pylint on win32
again ... it turns out one of the dependent packages contains
a write-protected test file and windows will choke when it tries to move
it into place. Fortunately we can just delete the file prior to
installing it in the final location, but we have to jump through
a couple of hoops to do so.

Also, make sure that we're flattening nested module names like
"logilab/common" into either safe basenames (logilab_common) or
host-specific subdirs (logilab\common) as needed.

* Scripts/webkitpy/common/system/autoinstall.py:
(AutoInstaller._url_downloaded_path):
(AutoInstaller._install):
(AutoInstaller.install):
* Scripts/webkitpy/thirdparty/__init__.py:
(AutoinstallImportHook._install_pylint):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (136440 => 136441)


--- trunk/Tools/ChangeLog	2012-12-03 22:48:39 UTC (rev 136440)
+++ trunk/Tools/ChangeLog	2012-12-03 22:49:54 UTC (rev 136441)
@@ -1,5 +1,30 @@
 2012-12-03  Dirk Pranke  <dpra...@chromium.org>
 
+        webkitpy: autoinstaller is failing on windows
+        https://bugs.webkit.org/show_bug.cgi?id=103699
+
+        Reviewed by Tony Chang.
+
+        Attempt to fix the python autoinstaller to work for pylint on win32
+        again ... it turns out one of the dependent packages contains
+        a write-protected test file and windows will choke when it tries to move
+        it into place. Fortunately we can just delete the file prior to
+        installing it in the final location, but we have to jump through
+        a couple of hoops to do so.
+
+        Also, make sure that we're flattening nested module names like
+        "logilab/common" into either safe basenames (logilab_common) or
+        host-specific subdirs (logilab\common) as needed.
+
+        * Scripts/webkitpy/common/system/autoinstall.py:
+        (AutoInstaller._url_downloaded_path):
+        (AutoInstaller._install):
+        (AutoInstaller.install):
+        * Scripts/webkitpy/thirdparty/__init__.py:
+        (AutoinstallImportHook._install_pylint):
+
+2012-12-03  Dirk Pranke  <dpra...@chromium.org>
+
         nrwt: clean up exception propagation / handling for interrupts and early exits
         https://bugs.webkit.org/show_bug.cgi?id=103830
 

Modified: trunk/Tools/Scripts/webkitpy/common/system/autoinstall.py (136440 => 136441)


--- trunk/Tools/Scripts/webkitpy/common/system/autoinstall.py	2012-12-03 22:48:39 UTC (rev 136440)
+++ trunk/Tools/Scripts/webkitpy/common/system/autoinstall.py	2012-12-03 22:49:54 UTC (rev 136441)
@@ -35,6 +35,7 @@
 import logging
 import os
 import shutil
+import stat
 import sys
 import tarfile
 import tempfile
@@ -173,7 +174,7 @@
         return scratch_dir
 
     def _url_downloaded_path(self, target_name):
-        return os.path.join(self._target_dir, ".%s.url" % target_name)
+        return os.path.join(self._target_dir, ".%s.url" % target_name.replace('/', '_'))
 
     def _is_downloaded(self, target_name, url):
         version_path = self._url_downloaded_path(target_name)
@@ -319,8 +320,7 @@
 
         return target_path
 
-    def _install(self, scratch_dir, package_name, target_path, url,
-                 url_subpath):
+    def _install(self, scratch_dir, package_name, target_path, url, url_subpath, files_to_remove):
         """Install a python package from an URL.
 
         This internal method overwrites the target path if the target
@@ -335,6 +335,13 @@
         else:
             source_path = os.path.join(path, url_subpath)
 
+        for filename in files_to_remove:
+            path = os.path.join(source_path, filename.replace('/', os.sep))
+            if os.path.exists(path):
+                # Pre-emptively change the permissions to #0777 to try and work around win32 permissions issues.
+                os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
+                os.remove(path)
+
         if os.path.exists(target_path):
             if os.path.isdir(target_path):
                 shutil.rmtree(target_path, ignore_errors=True)
@@ -354,7 +361,7 @@
         self._record_url_downloaded(package_name, url)
 
     def install(self, url, should_refresh=False, target_name=None,
-                url_subpath=None):
+                url_subpath=None, files_to_remove=None):
         """Install a python package from an URL.
 
         Args:
@@ -382,10 +389,11 @@
             url_subpath = os.path.normpath(url_subpath)
             target_name = os.path.basename(url_subpath)
 
-        target_path = os.path.join(self._target_dir, target_name)
+        target_path = os.path.join(self._target_dir, target_name.replace('/', os.sep))
         if not should_refresh and self._is_downloaded(target_name, url):
             return False
 
+        files_to_remove = files_to_remove or []
         package_name = target_name.replace(os.sep, '.')
         _log.info("Auto-installing package: %s" % package_name)
 
@@ -399,7 +407,8 @@
                           target_path=target_path,
                           scratch_dir=scratch_dir,
                           url=""
-                          url_subpath=url_subpath)
+                          url_subpath=url_subpath,
+                          files_to_remove=files_to_remove)
         except Exception, err:
             # Append existing Error message to new Error.
             message = ("Error auto-installing the %s package to:\n"

Modified: trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py (136440 => 136441)


--- trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py	2012-12-03 22:48:39 UTC (rev 136440)
+++ trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py	2012-12-03 22:49:54 UTC (rev 136441)
@@ -109,7 +109,10 @@
             not self._fs.exists(self._fs.join(_AUTOINSTALLED_DIR, "logilab/astng")) or
             not self._fs.exists(self._fs.join(_AUTOINSTALLED_DIR, "logilab/common"))):
             installer = AutoInstaller(target_dir=_AUTOINSTALLED_DIR)
-            did_install_something = installer.install("http://pypi.python.org/packages/source/l/logilab-common/logilab-common-0.58.1.tar.gz#md5=77298ab2d8bb8b4af9219791e7cee8ce", url_subpath="logilab-common-0.58.1", target_name="logilab/common")
+            files_to_remove = []
+            if sys.platform == 'win32':
+                files_to_remove = ['test/data/write_protected_file.txt']
+            did_install_something = installer.install("http://pypi.python.org/packages/source/l/logilab-common/logilab-common-0.58.1.tar.gz#md5=77298ab2d8bb8b4af9219791e7cee8ce", url_subpath="logilab-common-0.58.1", target_name="logilab/common", files_to_remove=files_to_remove)
             did_install_something |= installer.install("http://pypi.python.org/packages/source/l/logilab-astng/logilab-astng-0.24.1.tar.gz#md5=ddaf66e4d85714d9c47a46d4bed406de", url_subpath="logilab-astng-0.24.1", target_name="logilab/astng")
             did_install_something |= installer.install('http://pypi.python.org/packages/source/p/pylint/pylint-0.25.1.tar.gz#md5=728bbc2b339bc3749af013709a7f87a5', url_subpath="pylint-0.25.1", target_name="pylint")
         return did_install_something
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to