# -*- coding: utf-8 -*-

from setuphelpers import *

bin_name = "WinMerge-%s-Setup.exe"


def install():
    # Declaring local variables
    package_version = control.get_software_version()
    bin_name = glob.glob("WinMerge-*.exe")[0]

    # # Uninstalling older major versions of the software
    # for to_uninstall in installed_softwares(uninstallkey="WinMerge_is1"):
    #     if Version(to_uninstall["version"], 1) < Version(control.get_software_version(), 1) or force:
    #         print("Removing: %s (%s)" % (to_uninstall["name"], to_uninstall["version"]))
    #         killalltasks(ensure_list(control.impacted_process))
    #         run(uninstall_cmd(to_uninstall["key"]))
    #         wait_uninstallkey_absent(to_uninstall["key"])
    #         if isdir(to_uninstall["install_location"]):
    #             remove_tree(to_uninstall["install_location"])

    # Installing the software
    install_exe_if_needed(
        bin_name,
        silentflags="/VERYSILENT /SUPPRESSMSGBOXES /NORESTART",
        key="WinMerge_is1",
        min_version=control.get_software_version(),
    )
