diff --git a/core/pythonActionLoop/pythonbuild.py b/core/pythonActionLoop/pythonbuild.py index 30802c2d..b064f2d0 100755 --- a/core/pythonActionLoop/pythonbuild.py +++ b/core/pythonActionLoop/pythonbuild.py @@ -65,7 +65,7 @@ def build(source_dir, target_file, launcher): if os.path.isfile(main): cmd += """ cd %s -exec python %s "$@" +exec "$(which python)" %s "$@" """ % (source_dir, launcher) else: cmd += """ diff --git a/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala index 89d24265..f36b8d99 100644 --- a/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala +++ b/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala @@ -438,4 +438,22 @@ class PythonActionContainerTests extends BasicActionRunnerTests with WskActorSys e should include("Traceback") }) } + + it should "have a valid sys.executable" in { + withActionContainer() { c => + val code = + """ + |import sys + |def main(args): + | return { "sys": sys.executable } + """.stripMargin + + val (initCode, res) = c.init(initPayload(code)) + initCode should be(200) + + val (runCode, runRes) = c.run(runPayload(JsObject())) + runCode should be(200) + runRes.get.fields.get("sys").get.toString() should include("python") + } + } }