This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/incubator-openwhisk-runtime-python.git
The following commit(s) were added to refs/heads/master by this push:
new 6879887 helping python to find itself... (#50)
6879887 is described below
commit 6879887dbc112db12a10d61455287a6d605b87f9
Author: Michele Sciabarra <[email protected]>
AuthorDate: Tue Feb 19 10:36:25 2019 +0100
helping python to find itself... (#50)
* helping python to find itself...
* adding a test to ensure sys.executable is valid
* fixed format
---
core/pythonActionLoop/pythonbuild.py | 2 +-
.../actionContainers/PythonActionContainerTests.scala | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/core/pythonActionLoop/pythonbuild.py
b/core/pythonActionLoop/pythonbuild.py
index 30802c2..b064f2d 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 89d2426..f36b8d9 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")
+ }
+ }
}