Skip to content

Commit

Permalink
Merge pull request #19 from WhenLifeHandsYouLemons/v1.5.1
Browse files Browse the repository at this point in the history
Created v1.5.1 & bug fixes
  • Loading branch information
WhenLifeHandsYouLemons authored Feb 19, 2024
2 parents b320b81 + 329aebc commit f98a286
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 27 deletions.
Binary file removed encryptext_installer_v1.5.0_64bit.exe
Binary file not shown.
Binary file added encryptext_installer_v1.5.1_64bit.exe
Binary file not shown.
13 changes: 9 additions & 4 deletions installer_creator_windows.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
from os import system
import PyInstaller.__main__

version = "1.5.1"

# Creates an executable file
PyInstaller.__main__.run([
'installer_windows.py',
'--onefile',
'--clean',
'--log-level',
'CRITICAL',
'INFO',
'--icon',
'installer_icon.ico',
'--add-data',
'app_icon.ico;.',
'--add-data',
'Encryptext.pyw;.'
'Encryptext.pyw;.',
"--collect-all",
"tkinterweb"
])

# Moves the exe out of the dist folder
system("move dist\\installer_windows.exe encryptext_installer_v0.0.0_64bit.exe")
system(f"move dist\\installer_windows.exe encryptext_installer_v{version}_64bit.exe")

# Removes the "build" folder
system("rmdir /s /q build")
# Removes the "installer.spec" file
# Removes the "installer_windows.spec" file
system("del installer_windows.spec")
# Removes the "dist" folder
system("rmdir /s /q dist")
56 changes: 33 additions & 23 deletions installer_windows.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
from os import devnull, system
from os.path import abspath, join
from sys import _MEIPASS
import os
import sys
from subprocess import run
from time import sleep
from subprocess import check_call
from cryptography.fernet import Fernet as F
from random import choice, randint
from string import ascii_letters, digits
import threading as t

version = "1.5.1"

print("\nStarting installer...")
print("Please wait...")

# Used for getting files when using one-file mode .exe format
def getTrueFilename(filename):
try:
base = _MEIPASS
base = sys._MEIPASS
except Exception:
base = abspath(".")
return join(base, filename)
base = os.path.abspath(".")
return os.path.join(base, filename)

# Open the Encryptext.py file and read it into a variable
file = open(getTrueFilename("Encryptext.pyw"), "r", encoding="utf8")
Expand Down Expand Up @@ -98,10 +99,15 @@ def getTrueFilename(filename):
def appCreation():
file_path = getTrueFilename("Encryptext-User.pyw")
icon_path = getTrueFilename("app_icon.ico")
# https://github.com/pyinstaller/pyinstaller/issues/6658#issuecomment-1062817361
subproc_env = os.environ.copy()
subproc_env.pop('TCL_LIBRARY', None)
subproc_env.pop('TK_LIBRARY', None)

# https://stackoverflow.com/a/72523249
# https://stackoverflow.com/a/13790741
# https://stackoverflow.com/a/8529412
check_call(["pyinstaller",
command = ["pyinstaller",
"--onefile",
"--clean",
"--windowed",
Expand All @@ -113,11 +119,13 @@ def appCreation():
f"{icon_path};.",
"--name",
"Encryptext",
"--collect-all",
"tkinterweb",
file_path
],
shell=True,
stdout=open(devnull, 'wb'),
stderr=open(devnull, 'wb'))
]
# Redirect both stdout and stderr to /dev/null or NUL depending on the platform
with open(os.devnull, 'w') as null_file:
run(command, shell=True, env=subproc_env, stdout=null_file, stderr=null_file)

# https://stackoverflow.com/a/34325723
# Print iterations progress
Expand All @@ -137,30 +145,32 @@ def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1,
# Show a progress bar while app is compiling
l = 100
i = 0
speed = 1.75
printProgressBar(i, l, prefix='Progress:', suffix='Complete', length=50)
while i < l-25:
sleep(0.5)
while i < l-1:
sleep(speed)

if not app_thread.is_alive():
speed = 0.05

i += 1
printProgressBar(i, l, prefix='Progress:', suffix='Complete', length=50, printEnd='')

app_thread.join()

while i < l:
sleep(0.05)
i += 1
printProgressBar(i, l, prefix='Progress:', suffix='Complete', length=50, printEnd='')
printProgressBar(i+1, l, prefix='Progress:', suffix='Complete', length=50, printEnd='')

# Moves the exe out of the dist folder
system("move dist\\Encryptext.exe Encryptext.exe >nul")
os.system(f"move dist\\Encryptext.exe Encryptext_v{version}.exe >nul")

print("\r\n\nCreated program!")
print("Cleaning up...")

# Removes the "dist" folder
system("rmdir /s /q dist")
os.system("rmdir /s /q dist")
# Removes the "build" folder
system("rmdir /s /q build")
# Removes the "Encryptext-User.spec" file
system("del Encryptext.spec")
os.system("rmdir /s /q build")
# Removes the "Encryptext.spec" file
os.system("del Encryptext.spec")

input("\nCompleted! Press enter to finish setup...")
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ webbrowser
cryptography
tkinterweb
markdown
PyInstaller
threading

0 comments on commit f98a286

Please sign in to comment.