Skip to content

Instantly share code, notes, and snippets.

@htgoebel
Created August 29, 2019 16:20
Show Gist options
  • Save htgoebel/286c661b99ed3f6065511c9a26b50c63 to your computer and use it in GitHub Desktop.
Save htgoebel/286c661b99ed3f6065511c9a26b50c63 to your computer and use it in GitHub Desktop.
Taming RecursionError
0) Prepare a clean environment
python -m venv pyivenv
cd pyivenv
source ./bin/activate # Posix bash/zsh
.\Scripts\activate.bat # Windows cmd.exe
.\Scripts\Activate.ps1 # Windows PowerShell
pip install -U pip # upgrade pip
export PYTHONHASHSEED=0 # Posix
set PYTHONHASHSEED=0 # Windows cmd.exe
$env:PYTHONHASHSEED = "0" # Windows PowerShell
# verify hash randomization is disabled
python -c "import sys; assert sys.flags.hash_randomization == 0"
# install PyInstaller
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz
# go to you project and install its requirements
cd /path/to/you/application
pip install -r ....
pip list > pip-list.txt
pip freeze > pip-freeze.txt
Now comes the important part:
1) Generate a .spec-file (if you don't have one already):
pyi-makespec main.py
2) Verify pyinstaller runs into RecursionError in this setup:
pyinstaller main.spec
If this does *not* fail, ensure the .spec-file does *not*
`sys.setrecursionlimit()`
3) Please try to generate a as minimal as possible version of you application,
which will still make PyInstaller run into RecursionError. Ideally the
application only consists of on import statement and still fails to freeze.
Please, please take your time for doing so! The TRACE-output you will
generate in the next steps will be HUGE and hard to analyze anyway. Please
help keeping the data small. Otherwise I will have barely no chance to find
the error.
3) Run PyInstaller in TRACE mode, redirecting the
output into a file. The outout will be huge, several thousand lines,
so you really want to redirect the output into a file::
pyinstaller main.spec --log=TRACE > failing.log 2>&1
4) Now iterative try to find a *small* new recursion limit which will make
PyInstaller pass. Add this line to the .spec-file
sys.setrecursionlimit(sys.getrecursionlimit() + 10)
then run `pyinstaller main.spec` again. If it fails, increase the number,
if it passes, decrease the number. Repeat until you have a lower bound (in
steps 10) where PyInstaller passes.
With this lower bound run
pyinstaller main.spec --log=TRACE > passing.log 2>&1
5) Zip all the log-files and send them to my via email. You can find my E-Mail
at http://www.pyinstaller.org/support.html
zip trace-logs.zip pip-list.txt pip-freeze.txt failing.log passing.log
I only need these log-file, nothing of the stuff built.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment