Giter Site home page Giter Site logo

exe-generation-tutorial's Introduction

Exe generation

Documentation for exe generation.

  1. Virtual environment creation
  2. Setup your virtual environment
    1. Setup environment for a script
    2. Setup environment for a library
      1. With a requirements.txt file
      2. Without requirements.txt file
  3. EXE file generation
    1. EXE generation for a script
    2. EXE generation for a library
  4. 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 :
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 :

cd /Workspace
activate.bat

Now your virtual environment is running.

venv

Setup your virtual environment

Now we need to create our virtual environment with needed libraries.

Setup environment for a script

Install all your dependencies :

pip install <name of your library>

⚠ WARNING: At least, you need to install pyinstaller :

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 :

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 :

pip install <name of your library>

⚠ WARNING: At least, you need to install pyinstaller :

pip install pyinstaller

EXE file generation

EXE generation for a script

You just need to run :

pyinstaller --onefile <path-to-my-file>

EXE generation for a library

You just need to run :

pyinstaller <path-to-your-main-file> --paths <abslolute-path-to-your-library>

⚠ 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 :

pyinstaller --version-file=/Path/to/properties.rc <path-to-your-main-file> --paths <abslolute-path-to-your-library>

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 :

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])])
  ]
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.