Skip to main content

VersionInfo helper script for PyInstaller

Project description

VersionInfo helper script for PyInstaller

This repository contains helper scripts to dynamically create VersionInfo objects that can be embedded in .exe files created by PyInstaller.

Project Status

Category Workflow information
Published on PyPI PyPI - Version PyPI - Python Version 📦 Publish Python Package
Documentation Documentation on Github Pages 📚 Build and publish documentation
Tests Coverage Status 🔄 Integration Testing 🧪 Unittests with Coverage
Type annotations: inline 🔍 Typecheck: Mypy 🧠 Typecheck: Pyright 🦋 Typecheck: Pyrefly
Additional CI/CD workflows 🧹 Linters 🚦 Noxfile Self Check

Motivation

This project was created because existing solutions to embed version information inside executables relied on creating artifact files that get read (and eval-ed) by PyInstaller during the build process.
Dynamically creating such files essentially boiled down to inserting data in a string template, with no guides to the user if their entered data is valid or not.
A bit of exploration of PyInstaller's source code and official Microsoft documentation revealed that it should be possible to provide PyInstaller with necessary data straight from .spec files without file-read-and-eval step.
This approach has the added bonus of being type hint compatible, offering rich auto-complete in supported IDEs.

Installation

Wheels are available on PyPI, install with:

pip install versioninfo_helper

Usage

See example_simple.onefile.spec and example_dynamic.onefile.spec for examples on how to integrate VersionInfo creation directly into PyInstaller .spec files.

Snippet of .spec file with embedded VersionInfo generation:

...  # Skipped other parts of .spec file

def gen_version_info():  #  -> VSVersionInfo
    '''
    Helper function, which can be embedded in .spec file,
    generates VSVersionInfo instance for executable.
    '''
    from versioninfo_helper import CharsetCode
    from versioninfo_helper import LanguageID
    from versioninfo_helper import create_VersionInfo
    # version must be a tuple of 4 (16-bit) integers
    # hardcoded in this example, but can be generated dynamically as needed
    version = (1, 2, 3, 4)
    version_str = '.'.join(str(v) for v in version)

    return create_VersionInfo(
        version,
        strings=[
            {
                # all fields are described in included TypedDicts, 
                # so IDEs should offer auto-complete and type checks
                "lang_id": LanguageID.US_English,
                "charset_id": CharsetCode.Unicode,
                "fields": {
                    "CompanyName": 'Your Company Name LLC',
                    'FileDescription': f'AppName ({version_str})',
                    'FileVersion': f'{version_str}',
                    'InternalName': 'AppName.exe',
                    'LegalCopyright': '© 2026 Your Company Name LLC',
                    'OriginalFilename': 'AppName.exe',
                    'ProductName': 'AppName - Part of Product',
                    'ProductVersion': f'{version_str}',
                }
            }
        ]
    )

...  # Skipped other parts of .spec file

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='AppName',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    icon='icon.ico',
    version=gen_version_info()  # call your helper function here
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

versioninfo_helper-1.0.1.tar.gz (109.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

versioninfo_helper-1.0.1-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file versioninfo_helper-1.0.1.tar.gz.

File metadata

  • Download URL: versioninfo_helper-1.0.1.tar.gz
  • Upload date:
  • Size: 109.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for versioninfo_helper-1.0.1.tar.gz
Algorithm Hash digest
SHA256 16c6c24410edf422b4a178c9080cdd9821ad38085895a9d4f528da44b0eb3641
MD5 14847e48e061908f9f3d0821eec872db
BLAKE2b-256 1dcd9ef790ae56043d7c098d1401a2ae217a2bd9206996c726f7ea449e57511a

See more details on using hashes here.

Provenance

The following attestation bundles were made for versioninfo_helper-1.0.1.tar.gz:

Publisher: publish.yml on ReggX/versioninfo_helper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file versioninfo_helper-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for versioninfo_helper-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e10ac5aa8228b86c8ede344e414d5d44152fff7d621ff2375fb87909096cd98
MD5 1da7344349b757cb2be1adc1dc92ef98
BLAKE2b-256 a4ef4f04631ebaadeae0b6d3406a0f124d1911a41bf6142ce73c1b3427c4a474

See more details on using hashes here.

Provenance

The following attestation bundles were made for versioninfo_helper-1.0.1-py3-none-any.whl:

Publisher: publish.yml on ReggX/versioninfo_helper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page