Skip to content

Commit 8bdd0a7

Browse files
authored
Merge pull request #82 from Embarcadero/pyinstaller_sample
PyInstaller sample
2 parents e37da55 + 0fb1b02 commit 8bdd0a7

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import delphivcl
2+
input(delphivcl.__spec__)
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
4+
a = Analysis(
5+
['delphivclexecutable.py'],
6+
pathex=[],
7+
binaries=[],
8+
datas=[(r"C:\Users\lmbelo\AppData\Local\Programs\Python\Python311\Lib\site-packages\delphivcl", "delphivcl")],
9+
hiddenimports=[],
10+
hookspath=[],
11+
hooksconfig={},
12+
runtime_hooks=[],
13+
excludes=[],
14+
noarchive=False,
15+
)
16+
pyz = PYZ(a.pure)
17+
18+
exe = EXE(
19+
pyz,
20+
a.scripts,
21+
[],
22+
exclude_binaries=True,
23+
name='delphivclexecutable',
24+
debug=False,
25+
bootloader_ignore_signals=False,
26+
strip=False,
27+
upx=True,
28+
console=True,
29+
disable_windowed_traceback=False,
30+
argv_emulation=False,
31+
target_arch=None,
32+
codesign_identity=None,
33+
entitlements_file=None,
34+
)
35+
coll = COLLECT(
36+
exe,
37+
a.binaries,
38+
a.datas,
39+
strip=False,
40+
upx=True,
41+
upx_exclude=[],
42+
name='delphivclexecutable',
43+
)

samples/Installer/readme.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
DelphiVCL4Python - PyInstaller Sample[]()
2+
# DelphiVCL4Python - PyInstaller Sample
3+
4+
5+
This is a sample that shows the use of the [PyInstaller](https://pyinstaller.org/en/stable/) package to create executables.
6+
## Contents
7+
8+
* [1 Creating your app](#creating_your_app)
9+
* [2 Making the PyInstaller spec file](#making_pyinstaller_spec_file)
10+
* [3 Build your executable](#build_your_executable)
11+
12+
## Creating your app
13+
14+
First thing first, install delphivcl as follows (use terminal):
15+
```
16+
python -m pip install delphivcl
17+
```
18+
19+
Now let's install PyInstaller:
20+
```
21+
python -m pip install pyinstaller
22+
```
23+
24+
Create a new folder and call it "installer". Inside your project folder, create a file called "delphivclexecutable.py". Edit the "delphivclexecutable.py" content to look like follows:
25+
26+
```
27+
import delphivcl
28+
input(delphivcl.__spec__)
29+
```
30+
31+
## Making the PyInstaller spec file
32+
33+
Using a spec file will simplify your next buildings. Let's create a new spec file based upon project's main script file. In Terminal, run the following:
34+
35+
```
36+
cd installer
37+
pyi-makespec delphivclexecutable.py
38+
```
39+
40+
Now we need to setup the spec file to distribute the DelphiVCL package. Open the spec file and include the following code in the data list:
41+
42+
```
43+
(r"<<<<THE DELPHI VCL FOLDER IN YOUR SITE-PACKAGES>>>>", "delphivcl")
44+
```
45+
46+
This is how it looks to me:
47+
48+
```
49+
...
50+
datas=[(r"C:\Users\lmbelo\AppData\Local\Programs\Python\Python311\Lib\site-packages\delphivcl", "delphivcl")],
51+
...
52+
```
53+
Note: you can remove the "docs" folder from delphivcl to make it smaller.
54+
55+
## Build your executable
56+
57+
We're now ready to build the exectable. Use the following command in Terminal to proceed:
58+
59+
```
60+
pyinstaller delphivclexecutable.spec
61+
```
62+
63+
After that, you will see the dist folder within project's folder. The executable file will be available as "delphivclexecutable.exe". You can customize the spec file as needed.

0 commit comments

Comments
 (0)