merlimat commented on a change in pull request #2897: Add archive support to 
python instance
URL: https://github.com/apache/pulsar/pull/2897#discussion_r229880117
 
 

 ##########
 File path: pulsar-functions/instance/src/main/python/python_instance_main.py
 ##########
 @@ -102,6 +102,19 @@ def main():
       zpfile = zipfile.ZipFile(str(args.py), 'r')
       zpfile.extractall(os.path.dirname(str(args.py)))
     sys.path.insert(0, os.path.dirname(str(args.py)))
+  elif os.path.splitext(str(args.py))[1] == '.zip':
+    # Assumig zip file with format func.zip
+    # extract to folder function
+    # internal dir format 
+    # "func/src"
+    # "func/requirements.txt"
+    # "func/deps"
+    # run pip install to target folder  deps folder
+    zpfile = zipfile.ZipFile(str(args.py), 'r')
+    zpfile.extractall(os.path.dirname(str(args.py)))
+    cmd = "pip install -t %s -r %s/requirements.txt --no-index --find-links 
%s/deps" % (os.path.dirname(str(args.py), os.path.dirname(str(args.py), 
os.path.dirname(str(args.py))
+    os.system(cmd)
+    sys.path.insert(0, os.path.splitext(str(args.py))[1] + "/" + "src"))
 
 Review comment:
   We should have at least some integration tests. And documentation on that a 
zip file is allowed and what it's the expected format.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to