Skip to content

freecad_version_check

freecad.datamanager_wb.freecad_version_check

Runtime version checks for supported FreeCAD and Python versions.

This module validates that the current FreeCAD and Python runtime meet the minimum required versions for the workbench.

FC_COMMIT_REQUIRED = 33772 module-attribute

FC_MAJOR_VER_REQUIRED = 1 module-attribute

FC_MINOR_VER_REQUIRED = 0 module-attribute

FC_PATCH_VER_REQUIRED = 2 module-attribute

check_python_and_freecad_version()

Validate that the current runtime is compatible with the workbench.

This function checks:

  • The running Python version (must satisfy the minimum required by the supported FreeCAD releases).
  • The running FreeCAD version/commit (when available).

Failures are reported via App.Console.PrintWarning / PrintLog. No exception is raised; the workbench may continue to load with reduced functionality.

Source code in freecad/datamanager_wb/freecad_version_check.py
def check_python_and_freecad_version() -> None:
    """Validate that the current runtime is compatible with the workbench.

    This function checks:

    - The running Python version (must satisfy the minimum required by the
      supported FreeCAD releases).
    - The running FreeCAD version/commit (when available).

    Failures are reported via `App.Console.PrintWarning` / `PrintLog`.
    No exception is raised; the workbench may continue to load with reduced
    functionality.
    """

    if not (sys.version_info[0] == 3 and sys.version_info[1] >= 11):
        _warn_unsupported_python_version()
        return

    # Check FreeCAD version
    port = get_port()
    port.log(port.translate("Log", "Checking FreeCAD version\n"))
    major, minor, patch, gitver = _parse_freecad_version()

    if not check_supported_python_version(major, minor, patch, gitver):
        _warn_unsupported_freecad_version(
            major=major,
            minor=minor,
            patch=patch,
            gitver=gitver,
        )

check_supported_python_version(major_ver, minor_ver, patch_ver=0, git_ver=0)

Return whether the given FreeCAD version tuple meets the minimum.

Despite the historical name, this helper compares the provided FreeCAD version tuple against the minimum version constants defined in this module.

Parameters:

Name Type Description Default
major_ver int

FreeCAD major version.

required
minor_ver int

FreeCAD minor version.

required
patch_ver int

FreeCAD patch version.

0
git_ver int

FreeCAD build/commit number when available.

0

Returns:

Type Description
bool

True if the version is supported, otherwise False.

Source code in freecad/datamanager_wb/freecad_version_check.py
def check_supported_python_version(
    major_ver: int, minor_ver: int, patch_ver: int = 0, git_ver: int = 0
) -> bool:
    """Return whether the given FreeCAD version tuple meets the minimum.

    Despite the historical name, this helper compares the provided FreeCAD
    version tuple against the minimum version constants defined in this module.

    Args:
        major_ver: FreeCAD major version.
        minor_ver: FreeCAD minor version.
        patch_ver: FreeCAD patch version.
        git_ver: FreeCAD build/commit number when available.

    Returns:
        ``True`` if the version is supported, otherwise ``False``.
    """

    return (major_ver, minor_ver, patch_ver, git_ver) >= (
        FC_MAJOR_VER_REQUIRED,
        FC_MINOR_VER_REQUIRED,
        FC_PATCH_VER_REQUIRED,
        FC_COMMIT_REQUIRED,
    )