This is an automated email from the ASF dual-hosted git repository.
technoboy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 68e454544d4 [fix][function] Fix python instance not process zip file
correctly (#16697)
68e454544d4 is described below
commit 68e454544d45734129e67ab3032eae3e40ff664c
Author: jiangpengcheng <[email protected]>
AuthorDate: Wed Aug 3 13:58:48 2022 +0800
[fix][function] Fix python instance not process zip file correctly (#16697)
---
.../instance/src/main/python/python_instance_main.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pulsar-functions/instance/src/main/python/python_instance_main.py
b/pulsar-functions/instance/src/main/python/python_instance_main.py
index 631d5b47851..5f7669b9c4d 100755
--- a/pulsar-functions/instance/src/main/python/python_instance_main.py
+++ b/pulsar-functions/instance/src/main/python/python_instance_main.py
@@ -111,7 +111,7 @@ def main():
sys.exit(1)
if os.path.splitext(str(args.py))[1] == '.whl':
if args.install_usercode_dependencies:
- cmd = "pip install -t %s" % os.path.dirname(str(args.py))
+ cmd = "pip install -t %s" %
os.path.dirname(os.path.abspath(str(args.py)))
if args.dependency_repository:
cmd = cmd + " -i %s" % str(args.dependency_repository)
if args.extra_dependency_repository:
@@ -124,7 +124,7 @@ def main():
else:
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)))
+ sys.path.insert(0, os.path.dirname(os.path.abspath(str(args.py))))
elif os.path.splitext(str(args.py))[1] == '.zip':
# Assumig zip file with format func.zip
# extract to folder function
@@ -135,21 +135,21 @@ def main():
# 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]
+ basename = os.path.basename(os.path.splitext(str(args.py))[0])
deps_dir = os.path.join(os.path.dirname(str(args.py)), basename, "deps")
if os.path.isdir(deps_dir) and os.listdir(deps_dir):
# get all wheel files from deps directory
wheel_file_list = [os.path.join(deps_dir, f) for f in
os.listdir(deps_dir) if os.path.isfile(os.path.join(deps_dir, f)) and
os.path.splitext(f)[1] =='.whl']
- cmd = "pip install -t %s --no-index --find-links %s %s" %
(os.path.dirname(str(args.py)), deps_dir, " ".join(wheel_file_list))
+ cmd = "pip install -t %s --no-index --find-links %s %s" %
(os.path.dirname(os.path.abspath(str(args.py))), deps_dir, "
".join(wheel_file_list))
Log.debug("Install python dependencies via cmd: %s" % cmd)
retval = os.system(cmd)
if retval != 0:
print("Could not install user depedencies specified by the zip file")
sys.exit(1)
# add python user src directory to path
- sys.path.insert(0, os.path.join(os.path.dirname(str(args.py)), basename,
"src"))
+ sys.path.insert(0,
os.path.join(os.path.dirname(os.path.abspath(str(args.py))), basename, "src"))
log_file = os.path.join(args.logging_directory,
util.getFullyQualifiedFunctionName(function_details.tenant,
function_details.namespace, function_details.name),