This repository was archived by the owner on Mar 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
85 lines (78 loc) · 3.58 KB
/
build.py
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
78
79
80
81
82
83
84
85
import json
import os
import subprocess
import time
from subprocess import Popen
try:
manifestfile = open('manifest.json')
manifest = json.load(manifestfile)
exist=1
except FileNotFoundError as e:
print("Pyletron cannot find 'manifest.json' is missing! Please find it or make one.")
print("Use Pyletron Manifest Generator to create a 'manifest.json'")
print('https://github.com/pyletron/manifest-generator')
exist=0
time.sleep(10)
quit()
if os.path.exists('html')==False:
print("Pyletron cannot find 'html' folder, this folder must contain the web application contents like 'html, css, js' and so on.")
print("Please find or create the 'html' folder and insert all web contents into the folder then recompile/rebuild the application.")
print('Closing in 10 seconds')
time.sleep(10)
quit()
if os.path.exists('html')==True:
if os.path.exists('html/index.html')==False:
print("Pyletron cannot find 'index.html' in the 'html' folder, this file must exist in the root of the 'html' folder.")
print("Please find, rename or move the 'index.html' into the root of the 'html' folder.")
print("'index.html' is the html file the application will first open.")
print('Closing in 10 seconds')
time.sleep(10)
quit()
def createPython():
try:
pyFile = open("main.py", "x")
except FileExistsError as e:
os.remove('main.py')
pyFile = open("main.py", "x")
print("File from previous build exists, deleted 'main.py'")
pyLine = "webview.create_window('{}', 'html/index.html')\n".format(manifest['name'])
pyContents = ["import webview\n",pyLine,"webview.start()\n\n","# GENERATED BY PYLETRON\n","# https://github.com/pyletron/builder"]
pyFile.writelines(pyContents)
pyFile.close()
if exist==1:
print(manifest['name'])
print(manifest['console'])
print(manifest['onedir'])
print(manifest['icon'])
print(manifest['version'])
print("Note: Files and Folder will be left behind, the 'dist' folder will be your output")
if manifest['icon']=="":
if manifest['onedir']==True:
if manifest['console']==False:
createPython()
subprocess.Popen('pyinstaller --noconfirm --onedir --windowed --icon "pyletronIcon.ico" --add-data "html;html/" main.py ')
if manifest['console']==True:
createPython()
subprocess.Popen('pyinstaller --noconfirm --onedir --console --icon "pyletronIcon.ico" --add-data "html;html/" main.py')
if manifest['onedir']==False:
if manifest['console']==False:
createPython()
subprocess.Popen('pyinstaller --noconfirm --onefile --windowed --icon "pyletronIcon.ico" --add-data "html;html/" main.py ')
if manifest['console']==True:
createPython()
subprocess.Popen('pyinstaller --noconfirm --onefile --console --icon "pyletronIcon.ico" --add-data "html;html/" main.py')
else:
if manifest['onedir']==True:
if manifest['console']==False:
createPython()
subprocess.Popen('pyinstaller --noconfirm --onedir --windowed --icon "{}" --add-data "html;html/" main.py '.format(manifest['icon']))
if manifest['console']==True:
createPython()
subprocess.Popen('pyinstaller --noconfirm --onedir --console --icon "{}" --add-data "html;html/" main.py'.format(manifest['icon']))
if manifest['onedir']==False:
if manifest['console']==False:
createPython()
subprocess.Popen('pyinstaller --noconfirm --onefile --windowed --icon "{}" --add-data "html;html/" main.py '.format(manifest['icon']))
if manifest['console']==True:
createPython()
subprocess.Popen('pyinstaller --noconfirm --onefile --console --icon "{}" --add-data "html;html/" main.py'.format(manifest['icon']))