pyi_rth_django.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2005-2023, PyInstaller Development Team.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. #
  7. # The full license is in the file COPYING.txt, distributed with this software.
  8. #
  9. # SPDX-License-Identifier: Apache-2.0
  10. #-----------------------------------------------------------------------------
  11. # This Django rthook was tested with Django 1.8.3.
  12. def _pyi_rthook():
  13. import django.utils.autoreload
  14. _old_restart_with_reloader = django.utils.autoreload.restart_with_reloader
  15. def _restart_with_reloader(*args):
  16. import sys
  17. a0 = sys.argv.pop(0)
  18. try:
  19. return _old_restart_with_reloader(*args)
  20. finally:
  21. sys.argv.insert(0, a0)
  22. # Override restart_with_reloader() function, otherwise the app might complain that some commands do not exist;
  23. # e.g., runserver.
  24. django.utils.autoreload.restart_with_reloader = _restart_with_reloader
  25. _pyi_rthook()
  26. del _pyi_rthook