Skip to content

Commit

Permalink
reinstall loop fix
Browse files Browse the repository at this point in the history
  • Loading branch information
octimot committed Jun 5, 2024
1 parent fbcb146 commit 17c64af
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions storytoolkitai/core/post_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def reinstall_requirements():
os.path.dirname(os.path.abspath(__file__)), '..', '..', 'requirements.txt'
)

original_requirements = None

logger.info('Re-installing requirements.txt...')
logger.info('This may take a few minutes.')
try:
Expand Down Expand Up @@ -60,8 +62,9 @@ def reinstall_requirements():
[sys.executable, '-m', 'pip', 'install', '-r', requirements_file_path, '--no-cache-dir'])

# restore the original requirements
with open(requirements_file_path, 'w') as f:
f.writelines(original_requirements)
if original_requirements:
with open(requirements_file_path, 'w') as f:
f.writelines(original_requirements)
except Exception as e:
logger.error('Failed to install requirements.txt: {}'.format(e))
logger.warning('Please install the requirements.txt manually.')
Expand Down

0 comments on commit 17c64af

Please sign in to comment.