Skip to content

Commit 187e0cf

Browse files
[fix][fn] Make python install dependencies from requirements.txt (#20174)
Co-authored-by: tison <[email protected]>
1 parent 1b2a991 commit 187e0cf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pulsar-functions/instance/src/main/python/python_instance_main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,15 @@ def main():
207207
zpfile.extractall(os.path.dirname(str(args.py)))
208208
basename = os.path.basename(os.path.splitext(str(args.py))[0])
209209

210+
requirements_file = os.path.join(os.path.dirname(str(args.py)), basename, "requirements.txt")
211+
if os.path.isfile(requirements_file):
212+
cmd = "pip install -r %s" % requirements_file
213+
Log.debug("Install python dependencies via cmd: %s" % cmd)
214+
retval = os.system(cmd)
215+
if retval != 0:
216+
print("Could not install user depedencies specified by the requirements.txt file")
217+
sys.exit(1)
218+
210219
deps_dir = os.path.join(os.path.dirname(str(args.py)), basename, "deps")
211220

212221
if os.path.isdir(deps_dir) and os.listdir(deps_dir):

0 commit comments

Comments
 (0)