Changeset 250869 in webkit
- Timestamp:
- Oct 8, 2019 3:30:21 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r250868 r250869 1 2019-10-08 Jonathan Bedard <jbedard@apple.com> 2 3 Python 3: Add support to auto-importer 4 https://bugs.webkit.org/show_bug.cgi?id=201955 5 6 Reviewed by Aakash Jain. 7 8 * Scripts/test-webkitpy-python3: Auto-install everything. 9 * Scripts/webkitpy/common/system/autoinstall.py: Import urlopen and urlparse for Python3. 10 * Scripts/webkitpy/thirdparty/__init__.py: 11 (AutoinstallImportHook.find_module): Update function definition for Python3. 12 (AutoinstallImportHook._install_mechanize): Use Python 2/3 compatible version of mechanize. 13 (AutoinstallImportHook._install_requests): Update urllib3 and requests version. 14 (AutoinstallImportHook._install_coverage): Use Python 2/3 compatible version of coverage. 15 (AutoinstallImportHook.greater_than_equal_to_version): Use range instead of xrange. 16 (AutoinstallImportHook._install_selenium): Update urllib3 version. 17 (AutoinstallImportHook.install_chromedriver): 18 (AutoinstallImportHook.install_geckodriver): 19 (AutoinstallImportHook.get_latest_pypi_url): 20 (AutoinstallImportHook.install_binary): 21 * Scripts/webkitpy/thirdparty/__init___unittest.py: 22 (ThirdpartyTest): 23 (ThirdpartyTest.test_import_hook): Deleted. 24 1 25 2019-10-08 Yury Semikhatsky <yurys@chromium.org> 2 26 -
trunk/Tools/Scripts/test-webkitpy-python3
r250631 r250869 76 76 raise RuntimeError('No matching tests found.') 77 77 78 from webkitpy.thirdparty import autoinstall_everything 79 autoinstall_everything() 80 78 81 result = unittest.TextTestRunner(verbosity=int(options.verbose) + 1, failfast=options.stop_on_fail, buffer=not options.verbose).run(suite) 79 82 return len(result.errors) -
trunk/Tools/Scripts/webkitpy/common/system/autoinstall.py
r244513 r250869 40 40 import tarfile 41 41 import tempfile 42 import urllib243 import urlparse44 42 import zipfile 45 43 import re 46 44 from distutils import dir_util 47 45 from glob import glob 48 import urlparse49 46 import subprocess 47 48 if sys.version_info > (3, 0): 49 from urllib.request import urlopen 50 import urllib.parse as urlparse 51 else: 52 from urllib2 import urlopen 53 import urlparse 50 54 51 55 -
trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py
r247538 r250869 32 32 import re 33 33 import sys 34 import urllib2 34 35 if sys.version_info > (3, 0): 36 from urllib.error import URLError 37 from urllib.request import urlopen 38 else: 39 from urllib2 import URLError, urlopen 35 40 36 41 from collections import namedtuple … … 81 86 sys.path.insert(0, _AUTOINSTALLED_DIR) 82 87 83 def find_module(self, fullname, _):88 def find_module(self, fullname, path=None): 84 89 # This method will run before each import. See http://www.python.org/dev/peps/pep-0302/ 85 90 if '.autoinstalled' not in fullname: … … 122 127 123 128 def _install_mechanize(self): 124 self._install("https://files.pythonhosted.org/packages/source/m/mechanize/mechanize-0.2.5.tar.gz", 125 "mechanize-0.2.5/mechanize") 129 self._ensure_autoinstalled_dir_is_in_sys_path() 130 self._install("https://files.pythonhosted.org/packages/0b/02/ae6ceac1baeda530866a85075641cec12989bd8d31af6d5ab4a3e8c92f47/webencodings-0.5.1.tar.gz", 131 "webencodings-0.5.1/webencodings") 132 self._install("https://files.pythonhosted.org/packages/85/3e/cf449cf1b5004e87510b9368e7a5f1acd8831c2d6691edd3c62a0823f98f/html5lib-1.0.1.tar.gz", 133 "html5lib-1.0.1/html5lib") 134 self._install("https://files.pythonhosted.org/packages/64/f1/1aa4c96dea14e17a955019b0fc4ac1b8dfbc50e3c90970c1fb8882e74a7b/mechanize-0.4.3.tar.gz", 135 "mechanize-0.4.3/mechanize") 126 136 127 137 def _install_keyring(self): … … 176 186 self._install("https://files.pythonhosted.org/packages/fc/bb/a5768c230f9ddb03acc9ef3f0d4a3cf93462473795d18e9535498c8f929d/chardet-3.0.4.tar.gz", 177 187 "chardet-3.0.4/chardet") 178 self._install("https://files.pythonhosted.org/packages/fc/bb/a5768c230f9ddb03acc9ef3f0d4a3cf93462473795d18e9535498c8f929d/chardet-3.0.4.tar.gz",179 "chardet-3.0.4/chardet")180 188 self._install("https://files.pythonhosted.org/packages/ad/13/eb56951b6f7950cadb579ca166e448ba77f9d24efc03edd7e55fa57d04b7/idna-2.8.tar.gz", 181 189 "idna-2.8/idna") 182 self._install("https://files.pythonhosted.org/packages/ b1/53/37d82ab391393565f2f831b8eedbffd57db5a718216f82f1a8b4d381a1c1/urllib3-1.24.1.tar.gz",183 "urllib3-1.2 4.1/src/urllib3")184 self._install("https://files.pythonhosted.org/packages/ 52/2c/514e4ac25da2b08ca5a464c50463682126385c4272c18193876e91f4bc38/requests-2.21.0.tar.gz",185 "requests-2.2 1.0/requests")190 self._install("https://files.pythonhosted.org/packages/ff/44/29655168da441dff66de03952880c6e2d17b252836ff1aa4421fba556424/urllib3-1.25.6.tar.gz", 191 "urllib3-1.25.6/src/urllib3") 192 self._install("https://files.pythonhosted.org/packages/01/62/ddcf76d1d19885e8579acb1b1df26a852b03472c0e46d2b959a714c90608/requests-2.22.0.tar.gz", 193 "requests-2.22.0/requests") 186 194 187 195 def _install_pylint(self): … … 224 232 def _install_coverage(self): 225 233 self._ensure_autoinstalled_dir_is_in_sys_path() 226 self._install(url="https://files.pythonhosted.org/packages/ source/c/coverage/coverage-3.5.1.tar.gz", url_subpath="coverage-3.5.1/coverage")234 self._install(url="https://files.pythonhosted.org/packages/85/d5/818d0e603685c4a613d56f065a721013e942088047ff1027a632948bdae6/coverage-4.5.4.tar.gz", url_subpath="coverage-4.5.4/coverage") 227 235 228 236 def _install_twisted_15_5_0(self): … … 234 242 @staticmethod 235 243 def greater_than_equal_to_version(minimum, version): 236 for i in xrange(len(minimum.split('.'))):244 for i in range(len(minimum.split('.'))): 237 245 if int(version.split('.')[i]) > int(minimum.split('.')[i]): 238 246 return True … … 245 253 246 254 installer = AutoInstaller(prepend_to_search_path=True, target_dir=self._fs.join(_AUTOINSTALLED_DIR, "urllib3")) 247 installer.install(url="https://files.pythonhosted.org/packages/ b1/53/37d82ab391393565f2f831b8eedbffd57db5a718216f82f1a8b4d381a1c1/urllib3-1.24.1.tar.gz", url_subpath="urllib3-1.24.1")255 installer.install(url="https://files.pythonhosted.org/packages/ff/44/29655168da441dff66de03952880c6e2d17b252836ff1aa4421fba556424/urllib3-1.25.6.tar.gz", url_subpath="urllib3-1.25.6") 248 256 249 257 minimum_version = '3.5.0' … … 255 263 try: 256 264 url, url_subpath = self.get_latest_pypi_url('selenium') 257 except urllib2.URLError:265 except URLError: 258 266 # URL for installing the minimum required version. 259 267 url = 'https://files.pythonhosted.org/packages/ac/d7/1928416439d066c60f26c87a8d1b78a8edd64c7d05a0aa917fa97a8ee02d/selenium-3.5.0.tar.gz' … … 265 273 filename_postfix = get_driver_filename().chrome 266 274 if filename_postfix != "unsupported": 267 version = url lib2.urlopen(CHROME_DRIVER_URL + 'LATEST_RELEASE').read().strip()275 version = urlopen(CHROME_DRIVER_URL + 'LATEST_RELEASE').read().strip() 268 276 full_chrome_url = "{base_url}{version}/chromedriver_{os}.zip".format(base_url=CHROME_DRIVER_URL, version=version, os=filename_postfix) 269 277 self.install_binary(full_chrome_url, 'chromedriver') … … 272 280 filename_postfix = get_driver_filename().firefox 273 281 if filename_postfix != "unsupported": 274 firefox_releases_blob = url lib2.urlopen(FIREFOX_RELEASES_URL)282 firefox_releases_blob = urlopen(FIREFOX_RELEASES_URL) 275 283 firefox_releases_line_separated = json.dumps(json.load(firefox_releases_blob), indent=0).strip() 276 284 all_firefox_release_urls = "\n".join(re.findall(r'.*browser_download_url.*', firefox_releases_line_separated)) … … 284 292 def get_latest_pypi_url(self, package_name, url_subpath_format='{name}-{version}/{lname}'): 285 293 json_url = "https://pypi.org/pypi/%s/json" % package_name 286 response = url lib2.urlopen(json_url, timeout=30)294 response = urlopen(json_url, timeout=30) 287 295 data = json.load(response) 288 296 url = data['urls'][1]['url'] … … 293 301 self._install(url=url, target_name=name) 294 302 directory = os.path.join(_AUTOINSTALLED_DIR, name) 295 os.chmod(os.path.join(directory, name), 0 755)303 os.chmod(os.path.join(directory, name), 0o755) 296 304 open(os.path.join(directory, '__init__.py'), 'w+').close() 297 305 298 306 299 307 _hook = AutoinstallImportHook() 300 sys.meta_path. append(_hook)308 sys.meta_path.insert(0, _hook) 301 309 302 310 -
trunk/Tools/Scripts/webkitpy/thirdparty/__init___unittest.py
r221825 r250869 34 34 35 35 class ThirdpartyTest(unittest.TestCase): 36 def test_import_hook(self):37 # Add another import hook and make sure we get called.38 class MockImportHook(AutoinstallImportHook):39 def __init__(self):40 AutoinstallImportHook.__init__(self)41 self.buildbot_installed = False42 43 def _install_buildbot(self):44 self.buildbot_installed = True45 46 mock_import_hook = MockImportHook()47 try:48 # The actual AutoinstallImportHook should be installed before us,49 # so these modules will get installed before MockImportHook runs.50 sys.meta_path.append(mock_import_hook)51 # unused-variable, import failures - pylint: disable-msg=W0612,E0611,F040152 from webkitpy.thirdparty.autoinstalled import buildbot53 self.assertTrue(mock_import_hook.buildbot_installed)54 55 finally:56 sys.meta_path.remove(mock_import_hook)57 58 36 def test_imports(self): 59 37 # This method tests that we can actually import everything.
Note: See TracChangeset
for help on using the changeset viewer.