Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bessouat40/exe-generation-tutorial
Tutorial for exe generation
https://github.com/bessouat40/exe-generation-tutorial
Last synced: 1 day ago
JSON representation
Tutorial for exe generation
- Host: GitHub
- URL: https://github.com/bessouat40/exe-generation-tutorial
- Owner: Bessouat40
- Created: 2024-03-16T09:07:00.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-16T09:12:21.000Z (8 months ago)
- Last Synced: 2024-03-16T10:44:32.863Z (8 months ago)
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Exe generation
Documentation for exe generation.
1. [Virtual environment creation](#virtual-environment-creation)
2. [Setup your virtual environment](#setup-your-virtual-environment)
1. [Setup environment for a script](#setup-environment-for-a-script)
2. [Setup environment for a library](#setup-environment-for-a-library)
1. [With a requirements.txt file](#with-a-requirementstxt-file)
2. [Without requirements.txt file](#without-requirementstxt-file)
3. [EXE file generation](#exe-file-generation)
1. [EXE generation for a script](#exe-generation-for-a-script)
2. [EXE generation for a library](#exe-generation-for-a-library)
4. [Add properties to your EXE file](#add-properties-to-your-exe-file)## Virtual environment creation
First we need to create a virtual environment in order to reduce our exe file weight and his generation time.
We will add only necessaries libraries in this environment.
For that, we need to create a requirements.txt file listing all our dependencies.Then :
* Go in your directory :
```BASH
python -m venv myEnv
```Then you will have a new folder `myEnv` in your directory.
* Go to `myEnv/Scripts/` and copy `activate.bat` in your `C:\Workspace` directory.
* Finally :
```BASH
cd /Workspace
activate.bat
```Now your virtual environment is running.
![venv](venv.png)
## Setup your virtual environment
Now we need to create our virtual environment with needed libraries.
### Setup environment for a script
Install all your dependencies :
```bash
pip install
```> **⚠ WARNING: At least, you need to install pyinstaller :**
```bash
pip install pyinstaller
```### Setup environment for a library
#### With a requirements.txt file
If you have a `requirements.txt` file with all your dependencies, go to your project directory and run :
```BASH
python -m pip install -r requirements.txt
```> **⚠ WARNING: Don't forget to add pyinstaller in your requirements.txt file !!!**
#### Without requirements.txt file
Install all your dependencies :
```bash
pip install
```> **⚠ WARNING: At least, you need to install pyinstaller :**
```bash
pip install pyinstaller
```## EXE file generation
### EXE generation for a script
You just need to run :
```BASH
pyinstaller --onefile
```### EXE generation for a library
You just need to run :
```bash
pyinstaller --paths
```> **⚠ WARNING: If your library is at `/Workspace/dev/Library`, you need to specify `/Workspace/dev` for --paths parameter !**
## Add properties to your EXE file
If you want to add `Properties` to your executable file, you need to execute this command line :
```bash
pyinstaller --version-file=/Path/to/properties.rc --paths
````properties.rc` is the file wich contains all details of your executable file.
> **You can find an example `properties.rc` file in this Gitlab repository !**
*File example :*
```rc
VSVersionInfo(
ffi=FixedFileInfo(
filevers=(1, 0, 0, 0),
prodvers=(1, 0, 0, 0),
mask=0x3f,
flags=0x0,
OS=0x40004,
fileType=0x1,
subtype=0x0,
date=(0, 0)
),
kids=[
StringFileInfo(
[
StringTable(
u'040904B0',
[StringStruct(u'CompanyName', u'Company'),
StringStruct(u'FileDescription', u'Description of my script'),
StringStruct(u'FileVersion', u'1.0.0'),
StringStruct(u'InternalName', u'script'),
StringStruct(u'LegalCopyright', u'\xa9 MyScript. All rights reserved.'),
StringStruct(u'OriginalFilename', u'script.exe'),
StringStruct(u'ProductName', u'Script'),
StringStruct(u'ProductVersion', u'1.0.0')])
]),
VarFileInfo([VarStruct(u'Translation', [0, 0])])
]
)
```