Skip to content

Commit

Permalink
i hate the installer
Browse files Browse the repository at this point in the history
  • Loading branch information
WishMakers0 committed Nov 29, 2023
1 parent 3cfe4e1 commit 109cdc4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
42 changes: 36 additions & 6 deletions CPU-DJ.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from os.path import join, exists
import sys
import os
import io
import subprocess
from subprocess import PIPE
import platform
Expand Down Expand Up @@ -42,26 +43,55 @@ def get_requirements_txt():
else:
ret = "require_linux.txt"
return ret

def get_pip_cmd() -> list:
ret = []
if(platform.system() == "Windows"):
ret.append(join('.venv', VENV_BIN, 'pip'))
else:
ret.append(PYTHON_BIN, '-m', 'pip')
return ret

VENV_BIN = get_venv_bin_folder()
PYTHON_BIN = join(getcwd(), '.venv', VENV_BIN, 'python')
VENV_START_BIN = join(getcwd(), '.venv', VENV_BIN, 'activate')
VENV_START_BIN = join(getcwd(), '.venv', '')
VENV_DIR = join(getcwd(), '.venv')
SCRIPT_PATH = join(getcwd(), 'main.py')
REQ_TXT = get_requirements_txt()
CHECK_PACK_PATH = join(getcwd(), '.venv', 'FREEZE.txt')
PIP_PATH = get_pip_cmd()

#print(VENV_START_BIN)
def set_freeze_text() -> str:
return subprocess.check_output(get_pip_cmd() + ["freeze"], cwd=getcwd(), capture_output=True, text=True, shell=True)

def main():
freeze = ""
#freeze_support()

if (not exists(VENV_START_BIN)):
# start venv setup process
freeze_support()
create_venv(".venv")
else:
freeze = set_freeze_text()
freeze_current = ""
with io.open(CHECK_PACK_PATH, 'r') as fd:
temp = fd.read()
# WHY DO I HAVE TO **INCREMENT** THE STRING FOR IT TO BE ACCESSED??? AAAAA
freeze_current = freeze_current + temp
if (not freeze_current != freeze):
os.remove(CHECK_PACK_PATH)

if (not exists(CHECK_PACK_PATH)):
# install packages
print("Populating .venv...\n")
subprocess.run([join('.venv', VENV_BIN, 'pip'), "install", "-r", join(getcwd(), REQ_TXT)], cwd=getcwd(), stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
subprocess.run(get_pip_cmd() + ["install", "-r", join(getcwd(), REQ_TXT)], cwd=getcwd(), shell=True)
freeze = set_freeze_text()
with io.open(CHECK_PACK_PATH, 'w') as fd:
fd.write(freeze)
print("Finished population.")

process = subprocess.Popen([PYTHON_BIN, SCRIPT_PATH], shell=True)
process.wait()
#process = subprocess.Popen([PYTHON_BIN, SCRIPT_PATH], shell=True)
#process.wait()

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyinstaller --onedir --noconsole --clean --icon=./icon.ico ./main.py
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion launcher/build.bat

This file was deleted.

0 comments on commit 109cdc4

Please sign in to comment.