Skip to content

Commit

Permalink
making an installer is the hardest ngl
Browse files Browse the repository at this point in the history
  • Loading branch information
KorryKatti committed Apr 4, 2024
1 parent bcdf1e3 commit f961ec0
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions open.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@ def activate_virtualenv(env_name):
activate_cmd = os.path.join(env_name, 'bin', 'activate')
subprocess.run(f'source {activate_cmd}', shell=True)

def check_customtkinter_exists(env_name):
try:
subprocess.run(['python', '-m', 'pip', 'list', '--format=columns'], check=True)
pip_list_output = subprocess.check_output(['python', '-m', 'pip', 'list'], universal_newlines=True)
return 'customtkinter' in pip_list_output
except subprocess.CalledProcessError:
return False

def install_customtkinter(env_name):
print("Installing customtkinter...")
subprocess.run(['python', '-m', 'pip', 'install', 'customtkinter'])

def run_main():
subprocess.run(['python', 'main.py'])

def run_updater():
subprocess.run(['python', 'updater.py'])

def main():
env_name = "myenv"

Expand All @@ -32,12 +41,11 @@ def main():

activate_virtualenv(env_name)

if os.path.exists(os.path.join(env_name, 'lib', 'python3.x', 'site-packages', 'customtkinter', '__init__.py')):
print("Module 'customtkinter' found.")
run_main()
else:
print("Module 'customtkinter' not found.")
run_updater()
if not check_customtkinter_exists(env_name):
install_customtkinter(env_name)

# Now we can proceed with running main.py
run_main()

if __name__ == "__main__":
main()

0 comments on commit f961ec0

Please sign in to comment.