Resolves issue #31
This commit is contained in:
parent
d1d1a39a30
commit
f2249c4f6c
1 changed files with 23 additions and 1 deletions
24
main.py
24
main.py
|
@ -35,7 +35,29 @@ def get_pip_command():
|
|||
def install_dependencies():
|
||||
|
||||
pip_command = get_pip_command()
|
||||
subprocess.check_call([pip_command, 'install', '-r', 'requirements.txt', '--user'])
|
||||
|
||||
with open('requirements.txt', 'r') as req_file:
|
||||
|
||||
requirements = req_file.read().splitlines()
|
||||
|
||||
try:
|
||||
|
||||
with open('installedrequirements.txt', 'r') as installed_file:
|
||||
installed_requirements = installed_file.read().splitlines()
|
||||
|
||||
except FileNotFoundError:
|
||||
|
||||
installed_requirements = []
|
||||
|
||||
dependencies_to_install = [req for req in requirements if req not in installed_requirements]
|
||||
|
||||
if dependencies_to_install:
|
||||
|
||||
subprocess.check_call([pip_command, 'install'] + dependencies_to_install + ['--user'])
|
||||
|
||||
with open('installedrequirements.txt', 'a') as installed_file:
|
||||
for dependency in dependencies_to_install:
|
||||
installed_file.write(dependency + '\n')
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
print('SIGINT/SIGTERM aknowledged. Stopping script gracefully, please wait...')
|
||||
|
|
Loading…
Reference in a new issue