Bug 153712 - generate-inspector-gresource-manifest.py uses the wrong python interpreter
Summary: generate-inspector-gresource-manifest.py uses the wrong python interpreter
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-30 10:00 PST by Jeremy Huddleston Sequoia
Modified: 2016-01-30 12:01 PST (History)
2 users (show)

See Also:


Attachments
patch (2.57 KB, patch)
2016-01-30 10:50 PST, Jeremy Huddleston Sequoia
no flags Details | Formatted Diff | Diff
patch (2.08 KB, patch)
2016-01-30 10:51 PST, Jeremy Huddleston Sequoia
no flags Details | Formatted Diff | Diff
patch (2.06 KB, patch)
2016-01-30 10:55 PST, Jeremy Huddleston Sequoia
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Huddleston Sequoia 2016-01-30 10:00:25 PST
Originally reported at https://trac.macports.org/ticket/50472

configure finds an appropriate version of python:

:info:configure -- Found PythonInterp: /opt/local/bin/python2.7 (found suitable version "2.7.11", minimum required is "2.7.0") 

but the build still fails when executing the generate-inspector-gresource-manifest.py script when the first python executable in $PATH is version 2.6:

:info:build [ 86%] Generating ../../DerivedSources/webkit2gtk/InspectorGResourceBundle.xml
:info:build cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_www_webkit2-gtk/webkit2-gtk/work/build/Source/WebKit2 && /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_www_webkit2-gtk/webkit2-gtk/work/webkitgtk-2.11.4/Tools/gtk/generate-inspector-gresource-manifest.py --output=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_www_webkit2-gtk/webkit2-gtk/work/build/DerivedSources/webkit2gtk/InspectorGResourceBundle.xml 
...
:info:build Traceback (most recent call last):
:info:build   File "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_www_webkit2-gtk/webkit2-gtk/work/webkitgtk-2.11.4/Tools/gtk/generate-inspector-gresource-manifest.py", line 18, in <module>
:info:build     import argparse
:info:build ImportError: No module named argparse
:info:build make[2]: *** [DerivedSources/webkit2gtk/InspectorGResourceBundle.xml] Error 1

The issue is that the script is executed directly with a hash-bang of "#!/usr/bin/env python" whereas other python scripts are executed using the configured interpreter, eg:

:info:build cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_www_webkit2-gtk/webkit2-gtk/work/webkitgtk-2.11.4/Source/WebKit2 && /opt/local/bin/python2.7 /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_www_webkit2-gtk/webkit2-gtk/work/webkitgtk-2.11.4/Source/WebKit2/Scripts/generate-messages-header.py WebProcess/WebPage/WebPage.messages.in > /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_www_webkit2-gtk/webkit2-gtk/work/build/DerivedSources/WebKit2/WebPageMessages.h
Comment 1 Jeremy Huddleston Sequoia 2016-01-30 10:05:53 PST
I'm testing a patch now.
Comment 2 Jeremy Huddleston Sequoia 2016-01-30 10:50:25 PST
Created attachment 270310 [details]
patch
Comment 3 Jeremy Huddleston Sequoia 2016-01-30 10:51:41 PST
Created attachment 270311 [details]
patch
Comment 4 Jeremy Huddleston Sequoia 2016-01-30 10:55:59 PST
Created attachment 270312 [details]
patch
Comment 5 Jeremy Huddleston Sequoia 2016-01-30 10:56:56 PST
Sorry for the noise.  The first one contained unrelated changes and the second had an incorrect commit log.
Comment 6 Michael Catanzaro 2016-01-30 11:15:03 PST
Comment on attachment 270312 [details]
patch

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

> Source/WebKit2/PlatformGTK.cmake:648
> +    COMMAND ${PYTHON_EXECUTABLE} ${TOOLS_DIR}/gtk/generate-inspector-gresource-manifest.py --output=${DERIVED_SOURCES_WEBKIT2GTK_DIR}/InspectorGResourceBundle.xml ${InspectorFiles} ${DERIVED_SOURCES_WEBINSPECTORUI_DIR}/UserInterface/Protocol/InspectorBackendCommands.js

Ugh, I do not like working around the shebang in the file itself. I normally prefer to substitute the right python executable into the shebang with a configure replacement, but then the script would go in the build directory rather than Tools/gtk, and that's definitely undesired. r=me only because I'm pretty sure there's no better solution.

Normally, files that end in .py are understood to not be executable, and should not have shebangs. The python files under Tools/gtk don't seem to follow this rule.
Comment 7 WebKit Commit Bot 2016-01-30 12:01:51 PST
Comment on attachment 270312 [details]
patch

Clearing flags on attachment: 270312

Committed r195902: <http://trac.webkit.org/changeset/195902>
Comment 8 WebKit Commit Bot 2016-01-30 12:01:55 PST
All reviewed patches have been landed.  Closing bug.