Python 3: 2to3 script may not be in a user's path
https://bugs.webkit.org/show_bug.cgi?id=203213
Reviewed by Dewei Zhu.
* Scripts/webkitpy/thirdparty/__init__.py:
(AutoinstallImportHook.__init__): Remove executive dependencies.
(AutoinstallImportHook._install_beautifulsoup): Use multiprocess because 2to3 sets
Some undesirable global logging state.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251478 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index e1221ec..9962b3f 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,15 @@
+2019-10-23 Jonathan Bedard <jbedard@apple.com>
+
+ Python 3: 2to3 script may not be in a user's path
+ https://bugs.webkit.org/show_bug.cgi?id=203213
+
+ Reviewed by Dewei Zhu.
+
+ * Scripts/webkitpy/thirdparty/__init__.py:
+ (AutoinstallImportHook.__init__): Remove executive dependencies.
+ (AutoinstallImportHook._install_beautifulsoup): Use multiprocess because 2to3 sets
+ Some undesirable global logging state.
+
2019-10-23 Tim Horton <timothy_horton@apple.com>
prepare-ChangeLog should whine about not having tests in WebKit-only patches
diff --git a/Tools/Scripts/webkitpy/thirdparty/__init__.py b/Tools/Scripts/webkitpy/thirdparty/__init__.py
index 91e2346..dc0ed31 100644
--- a/Tools/Scripts/webkitpy/thirdparty/__init__.py
+++ b/Tools/Scripts/webkitpy/thirdparty/__init__.py
@@ -42,7 +42,6 @@
from distutils import spawn
from webkitpy.common.system.autoinstall import AutoInstaller
from webkitpy.common.system.filesystem import FileSystem
-from webkitpy.common.system.executive import Executive
_THIRDPARTY_DIR = os.path.dirname(__file__)
_AUTOINSTALLED_DIR = os.path.join(_THIRDPARTY_DIR, "autoinstalled")
@@ -78,9 +77,8 @@
class AutoinstallImportHook(object):
- def __init__(self, filesystem=None, executive=None):
+ def __init__(self, filesystem=None):
self._fs = filesystem or FileSystem()
- self._executive = executive or Executive()
def _ensure_autoinstalled_dir_is_in_sys_path(self):
# Some packages require that the are being put somewhere under a directory in sys.path.
@@ -218,7 +216,16 @@
did_download_bs4 = self._install("https://files.pythonhosted.org/packages/86/cd/495c68f0536dcd25f016e006731ba7be72e072280305ec52590012c1e6f2/beautifulsoup4-4.8.1.tar.gz",
"beautifulsoup4-4.8.1/bs4")
if did_download_bs4:
- self._executive.run_command(['2to3', '-w', self._fs.join(_AUTOINSTALLED_DIR, 'bs4')])
+ from multiprocessing import Process
+ from lib2to3.main import main
+
+ try:
+ sys.stdout = open(os.devnull, 'w')
+ process = Process(target=main, args=('lib2to3.fixes', ['-w', self._fs.join(_AUTOINSTALLED_DIR, 'bs4')]))
+ process.start()
+ process.join()
+ finally:
+ sys.stdout = sys.__stdout__
def _install_pylint(self):