-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
38 lines (31 loc) · 1.41 KB
/
Copy pathsetup.py
File metadata and controls
38 lines (31 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import subprocess
import pip
def setup():
# Check if the .env file exists
if not os.path.exists('.env'):
# Get the secret key, access key, and target group values from the user
access_key = input("Enter the value for the TIO_ACCESS_KEY: ")
secret_key = input("Enter the value for the TIO_SECRET_KEY: ")
target_group = input("Enter the value for the TARGET_GROUP: ")
# Create the .env file
with open('.env', 'w') as f:
f.write(f"TIO_ACCESS_KEY='{access_key}'\n")
f.write(f"TIO_SECRET_KEY='{secret_key}'\n")
f.write(f"TARGET_GROUP='{target_group}'\n")
# Check if the requirements.txt file exists
if os.path.exists('requirements.txt'):
# Get the set of installed packages
installed_packages = set(subprocess.run(['pip', 'freeze'], capture_output=True, text=True).stdout.strip().split('\n'))
# Get the set of dependencies
with open('requirements.txt', 'r') as f:
dependencies = set(line.strip() for line in f)
# Calculate the set of dependencies to install
dependencies_to_install = dependencies - installed_packages
# Install dependencies if they do not already exist
if dependencies_to_install:
subprocess.call(['pip', 'install'] + list(dependencies_to_install))
else:
print("All dependencies are already installed.")
if __name__ == '__main__':
setup()