Commit 1b35def8 authored by Daalen, Tim van's avatar Daalen, Tim van
Browse files

merged linux build commands from yesterdays test

parent a77d7a21
......@@ -15,23 +15,26 @@ This makes it rougly 30 seconds slower than the current variant.
# Run command in shell, stdout is printed to the screen
def run_cmd(cmd):
ps = run(cmd, stderr=STDOUT, shell=True, universal_newlines=True)
# Print anny errors
if system()[0].upper() == "W": # windows
ps = run(cmd, stderr=STDOUT, shell=True, universal_newlines=True)
ps = run(cmd, stderr=STDOUT, shell=True, universal_newlines=True, executable="/bin/bash")
# Print all errors
if ps.stderr != None:
print(f"commandline error: {ps.stderr}")
raise Exception("shell run error")
# Convert the .ui files to .py files
def ui_to_py(ui_folder):
def ui_to_py(ui_folder, python):
# python -m PyQt5.uic.pyuic -x main.ui -o
for ui_file in glob(ui_folder + '*'):
filename, ext = path.splitext(ui_file)
print(f"Converting {filename} to .py")
run_cmd(f"""python -m PyQt5.uic.pyuic -x {ui_file} -o {filename +".py"}""")
run_cmd(f"""{python} -m PyQt5.uic.pyuic -x {ui_file} -o {filename +".py"}""")
# Find and replace the pixelmap references... They are hardcoded
with open(filename +".py") as file:
with open(filename +".py", 'r') as file:
lines = file.readlines()
modified_lines = {}
for linenum, line in enumerate(lines):
......@@ -76,13 +79,15 @@ if __name__ == "__main__":
# Seperator for sending multiple commands in one commandline call
if system()[0].upper() == "W": # windows
cmd_sep = "&&"
python = "python" # python version
else: # Linux
cmd_sep = ";"
python = "python3"
# Step 1 Convert .ui files to .py files
# Remove py files if they already exist, recompiling is the best way to ensure they are up to date
ui_to_py(ui_folder, python)
# Step 2: Pyinstallers includes all dependencies in the environment, so we use a venv
# Step 2a, Ensure the folder for the venv exists
......@@ -90,9 +95,13 @@ if __name__ == "__main__":
# Step 2b, Create the venv if needed
venv_activate = venv + f"{sep}Scripts{sep}activate.bat"
if system()[0].upper() == "W": # windows
venv_activate = f"{venv}{sep}Scripts{sep}activate.bat"
venv_activate = f"source {venv}/bin/activate"
if (not path.exists(venv_activate)) or (not path.isfile(venv_activate)):
run_cmd(f"python -m venv {venv}")
run_cmd(f"{python} -m venv {venv}")
run_cmd(f"{venv_activate} {cmd_sep} python -m pip install --upgrade pip")
run_cmd(f"{venv_activate} {cmd_sep} pip install -r requirements.txt")
# Step 3, Activate venv and tun pyinstaller
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment