| 
 | 1 | +DelphiFMX4Python - PyInstaller Sample[]()  | 
 | 2 | +# DelphiFMX4Python - 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 delphifmx as follows (use terminal):  | 
 | 15 | +```  | 
 | 16 | +python -m pip install delphifmx  | 
 | 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 "delphifmxexecutable.py". Edit the "delphifmxexecutable.py" content to look like follows:  | 
 | 25 | + | 
 | 26 | +```  | 
 | 27 | +import delphifmx  | 
 | 28 | +input(delphifmx.__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 delphifmxexecutable.py  | 
 | 38 | +```  | 
 | 39 | + | 
 | 40 | +Now we need to setup the spec file to distribute the DelphiFMX package. Open the spec file and include the following code in the data list:  | 
 | 41 | + | 
 | 42 | +```  | 
 | 43 | +(r"<<<<THE DELPHI FMX FOLDER IN YOUR SITE-PACKAGES>>>>", "delphifmx")  | 
 | 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\delphifmx", "delphifmx")],  | 
 | 51 | +...  | 
 | 52 | +```  | 
 | 53 | +Note: you can remove the "docs" folder from delphifmx 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 delphifmxexecutable.spec  | 
 | 61 | +```  | 
 | 62 | + | 
 | 63 | +After that, you will see the dist folder within project's folder. The executable file will be available as "delphifmxexecutable.exe". You can customize the spec file as needed.  | 
0 commit comments