exebuilder 0.3.2__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: exebuilder
3
- Version: 0.3.2
3
+ Version: 0.4.0
4
4
  Summary: A simple EXE builder for Python files.
5
5
  Author: Victor Zou
6
6
  Project-URL: Homepage, https://github.com/qzou1222-alt/exebuilder
@@ -54,13 +54,13 @@ Runs the Python file as a temporary EXE.
54
54
  ## CLI
55
55
 
56
56
  ```bash
57
- exebuilder my_file.py
57
+ exebuilder my_file.py --logo my_pic.gif
58
58
  ```
59
59
 
60
60
  or
61
61
 
62
62
  ```bash
63
- python exebuilder.py my_file.py
63
+ python exebuilder.py my_file.py --logo my_pic.gif
64
64
  ```
65
65
 
66
66
  creates:
@@ -43,13 +43,13 @@ Runs the Python file as a temporary EXE.
43
43
  ## CLI
44
44
 
45
45
  ```bash
46
- exebuilder my_file.py
46
+ exebuilder my_file.py --logo my_pic.gif
47
47
  ```
48
48
 
49
49
  or
50
50
 
51
51
  ```bash
52
- python exebuilder.py my_file.py
52
+ python exebuilder.py my_file.py --logo my_pic.gif
53
53
  ```
54
54
 
55
55
  creates:
@@ -1,28 +1,26 @@
1
1
  """
2
- Build EXE files from Python files. (v0.3.2)
2
+ Build EXE files from Python files. (v0.4.0)
3
3
 
4
4
  Contents Updated!
5
5
  =================
6
6
 
7
- 1. Fixed some building and checking bug:
7
+ build() add a parameter "logo". Enter any picture.
8
8
 
9
- - runasexe can't catch some error;
9
+ Usage
10
+ -----
10
11
 
11
- - runasexe doesn't check exe is exists;
12
+ CLI:
12
13
 
13
- - runasexe building messege is always hidden;
14
+ exebuilder your_file.py --logo your_pic.png
14
15
 
15
- - runasexe can't check a file is python file.
16
+ Building Success
17
+ ```
16
18
 
17
- 2. Optimized some checking codes:
19
+ Python:
18
20
 
19
- - Added more warnings;
21
+ <<< exebuilder.build("your_file.py",logo="your_pic.png")
20
22
 
21
- - runasexe parameter "prt" disassemble to two parameters: "warnprt" and "buildprt";
22
-
23
- - All methods support .PY file now;
24
-
25
- - Unified warning messages.
23
+ Building Success
26
24
 
27
25
  Exebuilder
28
26
  ==========
@@ -36,7 +34,7 @@ Build a Python file into an EXE using PyInstaller.
36
34
  API
37
35
  ---
38
36
 
39
- - build(file, prt=True)
37
+ - build(file, logo=None, prt=True)
40
38
  Build an EXE from a Python file.
41
39
 
42
40
  - runasexe(file, warnprt=True, buildprt=False)
@@ -52,7 +50,9 @@ Utilities
52
50
  Built-in warning messages.
53
51
  """
54
52
  from pathlib import Path as _P
55
- __version__ = "0.3.2"
53
+ from PIL.Image import Image as _Image
54
+ PILImage=_Image
55
+ __version__ = "0.4.0"
56
56
  def is_pyfile(file:str|_P) -> bool:
57
57
  '''Return whether a file is a Python file.'''
58
58
  if isinstance(file,_P):
@@ -119,33 +119,48 @@ def runasexe(pyfile: str | _P, warnprt:bool=True, buildprt:bool=False):
119
119
  print(f"Running failed: {Warnings[4]}")
120
120
  return False
121
121
  return True
122
- def build(pyfile:str|_P, prt:bool=True) -> bool:
122
+ def build(pyfile:str|_P, logo:str|_P|PILImage|None=None,prt:bool=True) -> bool:
123
123
  '''Build an EXE from a python file. Prt controls whether messages are printed in the terminal.'''
124
124
  import subprocess
125
125
  import sys
126
- if isinstance(pyfile, _P):
127
- pyfile=str(pyfile)
128
- if not _P(pyfile).exists():
129
- if prt:
130
- print(f"Building failed: {Warnings[5]}")
131
- return False
132
- if not is_pyfile(pyfile):
133
- if prt:
134
- print(f"Building failed: {Warnings[1]}")
135
- return False
136
- try:
137
- subprocess.run([
138
- sys.executable, "-m", "PyInstaller",
139
- "--onefile",
140
- pyfile,
141
- ],check=True,
142
- stdout=subprocess.DEVNULL if not prt else None,
143
- stderr=subprocess.DEVNULL if not prt else None)
144
- except subprocess.CalledProcessError:
126
+ import tempfile
127
+ from PIL import Image
128
+ with tempfile.TemporaryDirectory() as temp:
129
+ temp=_P(temp)
130
+ def logo_prep():
131
+ nonlocal logo
132
+ if logo is None:
133
+ return
134
+ elif isinstance(logo,(str,_P)):
135
+ logo=Image.open(logo)
136
+ logo.seek(0)
137
+ logo.save(temp/"logo.ico")
138
+ logo_prep()
139
+ if isinstance(pyfile, _P):
140
+ pyfile=str(pyfile)
141
+ if not _P(pyfile).exists():
142
+ if prt:
143
+ print(f"Building failed: {Warnings[5]}")
144
+ return False
145
+ if not is_pyfile(pyfile):
146
+ if prt:
147
+ print(f"Building failed: {Warnings[1]}")
148
+ return False
149
+ try:
150
+ subprocess.run([
151
+ sys.executable, "-m", "PyInstaller",
152
+ "--onefile",
153
+ *(("--icon",
154
+ str(temp/"logo.ico")) if logo else ()),
155
+ pyfile,
156
+ ],check=True,
157
+ stdout=subprocess.DEVNULL if not prt else None,
158
+ stderr=subprocess.DEVNULL if not prt else None)
159
+ except subprocess.CalledProcessError:
160
+ if prt:
161
+ print(f"Building failed: {Warnings[2]}")
162
+ return False
145
163
  if prt:
146
- print(f"Building failed: {Warnings[2]}")
147
- return False
148
- if prt:
149
- print("Building success")
164
+ print("Building success")
150
165
  return True
151
166
  Warnings._private=True
@@ -8,6 +8,9 @@ def main():
8
8
  file = args[0]
9
9
  flags = args[1:]
10
10
  prt = "--quiet" not in flags
11
- build(file,prt)
11
+ logo=None
12
+ if "--logo" in flags:
13
+ logo=flags[flags.index("--logo")+1]
14
+ build(file,logo,prt)
12
15
  if __name__ == "__main__":
13
16
  main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: exebuilder
3
- Version: 0.3.2
3
+ Version: 0.4.0
4
4
  Summary: A simple EXE builder for Python files.
5
5
  Author: Victor Zou
6
6
  Project-URL: Homepage, https://github.com/qzou1222-alt/exebuilder
@@ -54,13 +54,13 @@ Runs the Python file as a temporary EXE.
54
54
  ## CLI
55
55
 
56
56
  ```bash
57
- exebuilder my_file.py
57
+ exebuilder my_file.py --logo my_pic.gif
58
58
  ```
59
59
 
60
60
  or
61
61
 
62
62
  ```bash
63
- python exebuilder.py my_file.py
63
+ python exebuilder.py my_file.py --logo my_pic.gif
64
64
  ```
65
65
 
66
66
  creates:
@@ -8,7 +8,7 @@ Issues = "https://github.com/qzou1222-alt/exebuilder/issues"
8
8
  exebuilder = "exebuilder.__main__:main"
9
9
  [project]
10
10
  name = "exebuilder"
11
- version = "0.3.2"
11
+ version = "0.4.0"
12
12
  authors = [
13
13
  { name="Victor Zou" }
14
14
  ]
File without changes