You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/10/31 21:50:10 UTC

[GitHub] merlimat commented on a change in pull request #2897: Add archive support to python instance

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:
users@infra.apache.org


With regards,
Apache Git Services