From 3d48a8fe88f0993e4163b8ca57f2c0c454912cce Mon Sep 17 00:00:00 2001 From: Michele Sciabarra Date: Mon, 18 Feb 2019 20:44:28 +0100 Subject: [PATCH 1/3] helping python to find itself... --- core/pythonActionLoop/pythonbuild.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 += """ From 28e22b9a27934726f9aaf927a4697de08ce60b72 Mon Sep 17 00:00:00 2001 From: Michele Sciabarra Date: Mon, 18 Feb 2019 23:22:15 +0100 Subject: [PATCH 2/3] adding a test to ensure sys.executable is valid --- .../PythonActionContainerTests.scala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala index 89d24265..500cb82e 100644 --- a/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala +++ b/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala @@ -438,4 +438,23 @@ 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") + } + } } From dc51fd9c48c37dd1ef8024b5c131dcc7a05c11f0 Mon Sep 17 00:00:00 2001 From: Michele Sciabarra Date: Tue, 19 Feb 2019 06:53:52 +0100 Subject: [PATCH 3/3] fixed format --- .../actionContainers/PythonActionContainerTests.scala | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala index 500cb82e..f36b8d99 100644 --- a/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala +++ b/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala @@ -439,7 +439,6 @@ class PythonActionContainerTests extends BasicActionRunnerTests with WskActorSys }) } - it should "have a valid sys.executable" in { withActionContainer() { c => val code = @@ -449,12 +448,12 @@ class PythonActionContainerTests extends BasicActionRunnerTests with WskActorSys | return { "sys": sys.executable } """.stripMargin - val (initCode, res) = c.init(initPayload(code)) - initCode should be(200) + 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") + val (runCode, runRes) = c.run(runPayload(JsObject())) + runCode should be(200) + runRes.get.fields.get("sys").get.toString() should include("python") } } }