Bug 203213 - Python 3: 2to3 script may not be in a user's path
Summary: Python 3: 2to3 script may not be in a user's path
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jonathan Bedard
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-10-21 14:52 PDT by Jonathan Bedard
Modified: 2019-10-23 09:58 PDT (History)
7 users (show)

See Also:


Attachments
Patch (2.70 KB, patch)
2019-10-21 15:03 PDT, Jonathan Bedard
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Bedard 2019-10-21 14:52:12 PDT
In <https://trac.webkit.org/changeset/251112/webkit>, I assumed users would have 2to3 on their path. This was a bad assumption (I have a machine which doesn't, as an example). It's also unnecessary because 2to3 is part of the Python 3 standard library, we can leverage that and call it directly.
Comment 1 Jonathan Bedard 2019-10-21 15:03:34 PDT
Created attachment 381464 [details]
Patch
Comment 2 dewei_zhu 2019-10-22 18:29:28 PDT
Comment on attachment 381464 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=381464&action=review

> Tools/Scripts/webkitpy/thirdparty/__init__.py:-221
> -            self._executive.run_command(['2to3', '-w', self._fs.join(_AUTOINSTALLED_DIR, 'bs4')])

It may be cleaner if we invoke  self._executive.run_command([os.path.join(os.path.dirname(lib2to3), "__main__.py"), '-w', self._fs.join(_AUTOINSTALLED_DIR, 'bs4')])
This way, we don't have to temporarily change sys.stdout and use mulitiprocessing module.
Comment 3 Jonathan Bedard 2019-10-23 07:59:57 PDT
Comment on attachment 381464 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=381464&action=review

>> Tools/Scripts/webkitpy/thirdparty/__init__.py:-221
>> -            self._executive.run_command(['2to3', '-w', self._fs.join(_AUTOINSTALLED_DIR, 'bs4')])
> 
> It may be cleaner if we invoke  self._executive.run_command([os.path.join(os.path.dirname(lib2to3), "__main__.py"), '-w', self._fs.join(_AUTOINSTALLED_DIR, 'bs4')])
> This way, we don't have to temporarily change sys.stdout and use mulitiprocessing module.

Then we'd have to figure out where 2to3 is installed.

I disliked this executive method in the first place, multiprocessing is a bit dirtier in this function, but I feel like it's cleaner for the caller.
Comment 4 WebKit Commit Bot 2019-10-23 08:43:03 PDT
Comment on attachment 381464 [details]
Patch

Clearing flags on attachment: 381464

Committed r251478: <https://trac.webkit.org/changeset/251478>
Comment 5 WebKit Commit Bot 2019-10-23 08:43:05 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Radar WebKit Bug Importer 2019-10-23 08:44:13 PDT
<rdar://problem/56540189>
Comment 7 dewei_zhu 2019-10-23 09:58:09 PDT
Comment on attachment 381464 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=381464&action=review

>>> Tools/Scripts/webkitpy/thirdparty/__init__.py:-221
>>> -            self._executive.run_command(['2to3', '-w', self._fs.join(_AUTOINSTALLED_DIR, 'bs4')])
>> 
>> It may be cleaner if we invoke  self._executive.run_command([os.path.join(os.path.dirname(lib2to3), "__main__.py"), '-w', self._fs.join(_AUTOINSTALLED_DIR, 'bs4')])
>> This way, we don't have to temporarily change sys.stdout and use mulitiprocessing module.
> 
> Then we'd have to figure out where 2to3 is installed.
> 
> I disliked this executive method in the first place, multiprocessing is a bit dirtier in this function, but I feel like it's cleaner for the caller.

We don't directly call the `2to3`, we still rely on `lib2to3` module as your initial change. Instead of calling binary '2to3' we invoke '__main__.py' file under root of lib2to3 module.