This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a commit to branch fix-compile-script
in repository https://gitbox.apache.org/repos/asf/openwhisk-runtime-python.git

commit b49284eb8e61513aec7cbdc6c1b790bdcc0610ef
Author: Rodric Rabbah <[email protected]>
AuthorDate: Sat Oct 10 10:31:00 2020 -0400

    Handle venv packaged from Windows.
---
 core/python2ActionLoop/bin/compile       | 7 +++++--
 core/python2ActionLoop/lib/launcher.py   | 4 +++-
 core/python3ActionLoop/bin/compile       | 7 +++++--
 core/python3ActionLoop/lib/launcher.py   | 4 +++-
 core/python3AiActionLoop/bin/compile     | 7 +++++--
 core/python3AiActionLoop/lib/launcher.py | 4 +++-
 6 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/core/python2ActionLoop/bin/compile 
b/core/python2ActionLoop/bin/compile
index 62b55e7..198ef18 100755
--- a/core/python2ActionLoop/bin/compile
+++ b/core/python2ActionLoop/bin/compile
@@ -87,9 +87,12 @@ def check(tgt_dir, module_name):
         if os.path.isdir(path_to_virtualenv):
             activate_this_file = path_to_virtualenv + '/bin/activate_this.py'
             if not os.path.exists(activate_this_file):
-               sys.stderr.write('Invalid virtualenv. Zip file does not include 
activate_this.py')
+                # check if this was packaged for windows
+                activate_this_file = path_to_virtualenv + 
'/Scripts/activate_this.py'
+            if not os.path.exists(activate_this_file):
+                sys.stderr.write("Invalid virtualenv. Zip file does not 
include 'activate_this.py'.\n")
     except ImportError:
-        sys.stderr.write("Zip file does not include %s" % module_name)
+        sys.stderr.write("Zip file does not include %s\n" % module_name)
     except SyntaxError as er:
         sys.stderr.write(er.msg)
     except Exception as ex:
diff --git a/core/python2ActionLoop/lib/launcher.py 
b/core/python2ActionLoop/lib/launcher.py
index 3204c9c..3aa3272 100755
--- a/core/python2ActionLoop/lib/launcher.py
+++ b/core/python2ActionLoop/lib/launcher.py
@@ -27,12 +27,14 @@ try:
   if os.path.isdir(path_to_virtualenv):
     # activate the virtualenv using activate_this.py contained in the 
virtualenv
     activate_this_file = path_to_virtualenv + '/bin/activate_this.py'
+    if not os.path.exists(activate_this_file): # try windows path
+      activate_this_file = path_to_virtualenv + '/Scripts/activate_this.py'
     if os.path.exists(activate_this_file):
       with open(activate_this_file) as f:
         code = compile(f.read(), activate_this_file, 'exec')
         exec(code, dict(__file__=activate_this_file))
     else:
-      sys.stderr.write('Invalid virtualenv. Zip file does not include 
/virtualenv/bin/' + os.path.basename(activate_this_file) + '\n')
+      sys.stderr.write("Invalid virtualenv. Zip file does not include 
'activate_this.py'.\n")
       sys.exit(1)
 except Exception:
   traceback.print_exc(file=sys.stderr, limit=0)
diff --git a/core/python3ActionLoop/bin/compile 
b/core/python3ActionLoop/bin/compile
index d8eba62..9e01cb2 100755
--- a/core/python3ActionLoop/bin/compile
+++ b/core/python3ActionLoop/bin/compile
@@ -89,9 +89,12 @@ def check(tgt_dir, module_name):
             if os.path.isdir(path_to_virtualenv):
                 activate_this_file = path_to_virtualenv + 
'/bin/activate_this.py'
                 if not os.path.exists(activate_this_file):
-                   sys.stderr.write('Invalid virtualenv. Zip file does not 
include activate_this.py')
+                    # check if this was packaged for windows
+                    activate_this_file = path_to_virtualenv + 
'/Scripts/activate_this.py'
+                if not os.path.exists(activate_this_file):
+                    sys.stderr.write("Invalid virtualenv. Zip file does not 
include 'activate_this.py'.\n")
         else:
-            sys.stderr.write("Zip file does not include %s" % module_name)
+            sys.stderr.write("Zip file does not include %s\n" % module_name)
     except SyntaxError as er:
         sys.stderr.write(er.msg)
     except Exception as ex:
diff --git a/core/python3ActionLoop/lib/launcher.py 
b/core/python3ActionLoop/lib/launcher.py
index 9773570..ccf0c68 100755
--- a/core/python3ActionLoop/lib/launcher.py
+++ b/core/python3ActionLoop/lib/launcher.py
@@ -27,12 +27,14 @@ try:
   if os.path.isdir(path_to_virtualenv):
     # activate the virtualenv using activate_this.py contained in the 
virtualenv
     activate_this_file = path_to_virtualenv + '/bin/activate_this.py'
+    if not os.path.exists(activate_this_file): # try windows path
+      activate_this_file = path_to_virtualenv + '/Scripts/activate_this.py'
     if os.path.exists(activate_this_file):
       with open(activate_this_file) as f:
         code = compile(f.read(), activate_this_file, 'exec')
         exec(code, dict(__file__=activate_this_file))
     else:
-      sys.stderr.write('Invalid virtualenv. Zip file does not include 
/virtualenv/bin/' + os.path.basename(activate_this_file) + '\n')
+      sys.stderr.write("Invalid virtualenv. Zip file does not include 
'activate_this.py'.\n")
       sys.exit(1)
 except Exception:
   traceback.print_exc(file=sys.stderr, limit=0)
diff --git a/core/python3AiActionLoop/bin/compile 
b/core/python3AiActionLoop/bin/compile
index d8eba62..9e01cb2 100755
--- a/core/python3AiActionLoop/bin/compile
+++ b/core/python3AiActionLoop/bin/compile
@@ -89,9 +89,12 @@ def check(tgt_dir, module_name):
             if os.path.isdir(path_to_virtualenv):
                 activate_this_file = path_to_virtualenv + 
'/bin/activate_this.py'
                 if not os.path.exists(activate_this_file):
-                   sys.stderr.write('Invalid virtualenv. Zip file does not 
include activate_this.py')
+                    # check if this was packaged for windows
+                    activate_this_file = path_to_virtualenv + 
'/Scripts/activate_this.py'
+                if not os.path.exists(activate_this_file):
+                    sys.stderr.write("Invalid virtualenv. Zip file does not 
include 'activate_this.py'.\n")
         else:
-            sys.stderr.write("Zip file does not include %s" % module_name)
+            sys.stderr.write("Zip file does not include %s\n" % module_name)
     except SyntaxError as er:
         sys.stderr.write(er.msg)
     except Exception as ex:
diff --git a/core/python3AiActionLoop/lib/launcher.py 
b/core/python3AiActionLoop/lib/launcher.py
index 9773570..ccf0c68 100755
--- a/core/python3AiActionLoop/lib/launcher.py
+++ b/core/python3AiActionLoop/lib/launcher.py
@@ -27,12 +27,14 @@ try:
   if os.path.isdir(path_to_virtualenv):
     # activate the virtualenv using activate_this.py contained in the 
virtualenv
     activate_this_file = path_to_virtualenv + '/bin/activate_this.py'
+    if not os.path.exists(activate_this_file): # try windows path
+      activate_this_file = path_to_virtualenv + '/Scripts/activate_this.py'
     if os.path.exists(activate_this_file):
       with open(activate_this_file) as f:
         code = compile(f.read(), activate_this_file, 'exec')
         exec(code, dict(__file__=activate_this_file))
     else:
-      sys.stderr.write('Invalid virtualenv. Zip file does not include 
/virtualenv/bin/' + os.path.basename(activate_this_file) + '\n')
+      sys.stderr.write("Invalid virtualenv. Zip file does not include 
'activate_this.py'.\n")
       sys.exit(1)
 except Exception:
   traceback.print_exc(file=sys.stderr, limit=0)

Reply via email to