pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] srkukarni commented on a change in pull request #2915: Added ability to take python zip files that contain all their dependencies
Date Fri, 02 Nov 2018 21:35:53 GMT
srkukarni commented on a change in pull request #2915: Added ability to take python zip files
that contain all their dependencies
URL: https://github.com/apache/pulsar/pull/2915#discussion_r230515294
 
 

 ##########
 File path: pulsar-functions/instance/src/main/python/python_instance_main.py
 ##########
 @@ -102,6 +102,22 @@ 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)))
+    basename = os.path.splitext(str(args.py))[0]
+    requirements_txt_file = os.path.join(os.path.dirname(str(args.py)), basename, "requirements.txt")
+    deps_file = os.path.join(os.path.dirname(str(args.py)), basename, "deps")
+    cmd = "pip install -t %s -r %s --no-index --find-links %s" % (os.path.dirname(str(args.py)),
requirements_txt_file, deps_file)
+    os.system(cmd)
 
 Review comment:
   Done

----------------------------------------------------------------
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

Mime
View raw message