# -*- coding: utf-8 -*-
from setuphelpers import *


def install():
    # Declaring local variables
    bin_name = glob.glob("pingplotter_install.exe")[0]
    msi_bin_name = makepath(basedir, "PingPlotter.msi")

    # Extract the MSI file from the exe installer
    run(f'"{bin_name}" /extract="{msi_bin_name}"')

    # Installation du logiciel
    install_msi_if_needed(
        msi_bin_name,
        name = f"PingPlotter {str(Version(control.get_software_version(), 1))}",
        min_version=control.get_software_version(),
        get_version=get_version
    )

def get_version(uninstall_key):
    return str(Version(uninstall_key['version'], 3))