[fix][function] Fix python instance not process zip file correctly
@@ -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),
