74 lines
2.1 KiB
Python
74 lines
2.1 KiB
Python
"""
|
|
"""
|
|
|
|
# --------------------------------------- #
|
|
# imports #
|
|
# --------------------------------------- #
|
|
from invoke import task
|
|
|
|
import os
|
|
import shutil
|
|
|
|
# --------------------------------------- #
|
|
# definitions #
|
|
# --------------------------------------- #
|
|
VIRTUALENV_NAME = "py39_MailOrderParser"
|
|
EXECUTABLE_NAME = "MOP"
|
|
|
|
# --------------------------------------- #
|
|
# global vars #
|
|
# --------------------------------------- #
|
|
|
|
|
|
# --------------------------------------- #
|
|
# functions #
|
|
# --------------------------------------- #
|
|
def remove_temporary_folders():
|
|
print("-> remove unused folders")
|
|
for folder in ["dist", "build", "temp"]:
|
|
if os.path.exists(folder):
|
|
print("remove: {}".format(folder))
|
|
shutil.rmtree(folder)
|
|
print("finished!")
|
|
|
|
|
|
# --------------------------------------- #
|
|
# classes #
|
|
# --------------------------------------- #
|
|
@task
|
|
def update_requirements(cmd):
|
|
with cmd.prefix("workon {}".format(VIRTUALENV_NAME)):
|
|
cmd.run("pip freeze > requirements.txt")
|
|
|
|
|
|
@task
|
|
def create_exe(c, version="v9-9-9"):
|
|
with c.prefix("workon {}".format(VIRTUALENV_NAME)):
|
|
|
|
print("---------- START CREATING EXE ----------")
|
|
remove_temporary_folders()
|
|
|
|
print("-> start creating .exe")
|
|
c.run("pyinstaller start_app.spec")
|
|
print("finished!")
|
|
|
|
print("-> start creating temporary folders and copy files")
|
|
for folder in ["temp", "temp/apps"]:
|
|
os.mkdir(folder)
|
|
|
|
shutil.copyfile("dist/{}.exe".format(EXECUTABLE_NAME), "temp/apps/{}.exe".format(EXECUTABLE_NAME))
|
|
|
|
print("finished!")
|
|
print("-> start creating .zip")
|
|
|
|
zip_name = EXECUTABLE_NAME + "_" + version
|
|
|
|
shutil.make_archive(zip_name, "zip", "temp")
|
|
print("finished!")
|
|
remove_temporary_folders()
|
|
print("---------- FINISHED CREATING EXE ----------")
|
|
|
|
# --------------------------------------- #
|
|
# main #
|
|
# --------------------------------------- #
|