Skip to content

Commit

Permalink
hooks: langchain: automatically raise recursion limit
Browse files Browse the repository at this point in the history
Several tests on the CI are throwing recursion error with `langchain`
installed, so have the `langchain` hook automatically raise the
recursion limit to 5000 (unless it is already at higher value).
  • Loading branch information
rokm committed Feb 3, 2025
1 parent 06ec2b9 commit 67604eb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion _pyinstaller_hooks_contrib/stdhooks/hook-langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------

from PyInstaller.utils.hooks import collect_data_files
import sys

from PyInstaller.utils.hooks import collect_data_files, logger

datas = collect_data_files('langchain')

# Automatically raise recursion limit to ensure it is at least 5000; this attempts to mitigate recursion limit errors
# caused by some import chains that involve langchain, but also depend on the build environment (i.e., other packages
# installed in it).
new_limit = 5000
if sys.getrecursionlimit() < new_limit:
logger.info("hook-langchain: raising recursion limit to %d", new_limit)
sys.setrecursionlimit(new_limit)

0 comments on commit 67604eb

Please sign in to comment.