Skip to main content

WebView2 installer for Windows

Project description

WebView2 Installer

Документация на русском

A library for checking and automatically installing the WebView2 Evergreen Runtime on Windows.

Supported architectures: x86, x64, ARM64.

📦 Distribution Methods

1. Python Package (wheel)

pip install webview2-installer

2. DLL Library

Pre-built DLL files for integration into C/C++ projects:

  • webview2_installer_x86.dll — for 32-bit Windows
  • webview2_installer_x64.dll — for 64-bit Windows
  • webview2_installer_arm64.dll — for ARM64 Windows

🚀 Usage in Python

from webview2_installer import (
    is_webview2_installed,
    install_webview2_if_not_installed,
    download_and_install_webview2
)

# Check if WebView2 is installed
if is_webview2_installed():
    print("✅ WebView2 is already installed")
else:
    print("❌ WebView2 not found")

# Install if not installed (recommended method)
result = install_webview2_if_not_installed(verbose=True)
if result == 0:
    print("✅ WebView2 is already installed")
elif result == 1:
    print("✅ WebView2 installation started")
else:
    print("❌ WebView2 installation failed")

# Force download and installation
success = download_and_install_webview2(verbose=True)
if success:
    print("✅ Installation successfully started")

Return values for install_webview2_if_not_installed()

Value Description
0 WebView2 is already installed
1 Installation successfully started
-1 Installation failed

🔧 Using the DLL in C/C++

Function Signatures

// Checks if WebView2 is installed
bool is_webview2_installed(void);

// Downloads and installs WebView2 (silent installation)
bool download_and_install_webview2(void);

// With verbose output
bool download_and_install_webview2_verbose(void);

// Installs if not installed (0 = already installed, 1 = success, -1 = error)
int install_webview2_if_not_installed(void);

// With verbose output
int install_webview2_if_not_installed_verbose(void);

C Example

#include <windows.h>
#include <stdio.h>

typedef bool (*is_installed_fn)(void);
typedef int (*install_if_needed_fn)(void);

int main() {
    HMODULE dll = LoadLibrary("webview2_installer_x64.dll");
    if (!dll) return 1;
    
    is_installed_fn is_installed = (is_installed_fn)GetProcAddress(dll, "is_webview2_installed");
    install_if_needed_fn install_if_needed = (install_if_needed_fn)GetProcAddress(dll, "install_webview2_if_not_installed");
    
    if (is_installed && install_if_needed) {
        int result = install_if_needed();
        printf("Result: %d\n", result);
    }
    
    FreeLibrary(dll);
    return 0;
}

🛠️ Development and Building

Requirements

  • Rust (2021 edition)
  • Python 3.8+
  • Visual Studio Build Tools (Windows)
  • cargo, rustup
  • rcedit

Building the DLL

# Build release versions for all architectures
python build_dll.py

# Build debug versions
python build_dll.py --debug

# Dynamic linking (requires VC++ Redist)
python build_dll.py --dynamic

Building the Python Package

# Install development dependencies
pip install -e ".[dev]"

# Build the package
python -m build

# Or via devscript
devscript build_wheel

Cleaning Build Files

devscript clean

📋 System Requirements

  • OS: Windows 7 / 8 / 10 / 11
  • Architectures: x86, x64, ARM64
  • Python: 3.8+ (for Python package)
  • Internet: required for downloading the installer

🔍 How It Works

  • Installation Check: Checks for WebView2 registry keys in Windows registry
  • Download: Downloads the official Microsoft installer
  • Installation: Runs in silent mode (/silent /install)
  • Cleanup: Temporary files are automatically deleted

📄 License

MIT License

🤝 Contributing

PRs and Issues are welcome! Please ensure changes work on all target architectures.

⚠️ Known Limitations

  • Windows only (target platform)
  • Synchronous installation — you need to wait for WebView2 to finish installing

WebView2 Installer

Documentation in English

Библиотека для проверки установки и автоматической установки WebView2 Evergreen Runtime на Windows.

Поддерживает архитектуры: x86, x64, ARM64.

📦 Способы распространения

1. Python пакет (wheel)

pip install webview2-installer

2. DLL библиотека

Готовые DLL файлы для интеграции в C/C++ проекты:

  • webview2_installer_x86.dll — для 32-bit Windows
  • webview2_installer_x64.dll — для 64-bit Windows
  • webview2_installer_arm64.dll — для ARM64 Windows

🚀 Использование в Python

from webview2_installer import (
    is_webview2_installed,
    install_webview2_if_not_installed,
    download_and_install_webview2
)

# Проверить, установлен ли WebView2
if is_webview2_installed():
    print("✅ WebView2 уже установлен")
else:
    print("❌ WebView2 не найден")

# Установить, если не установлен (рекомендуемый способ)
result = install_webview2_if_not_installed(verbose=True)
if result == 0:
    print("✅ WebView2 уже установлен")
elif result == 1:
    print("✅ Установка WebView2 запущена")
else:
    print("❌ Ошибка установки WebView2")

# Принудительная загрузка и установка
success = download_and_install_webview2(verbose=True)
if success:
    print("✅ Установка успешно запущена")

Возвращаемые значения install_webview2_if_not_installed()

Значение Описание
0 WebView2 уже установлен
1 Установка успешно запущена
-1 Ошибка установки

🔧 Использование DLL в C/C++

Сигнатуры функций

// Проверяет установлен ли WebView2
bool is_webview2_installed(void);

// Загружает и устанавливает WebView2 (тихая установка)
bool download_and_install_webview2(void);

// С подробным выводом
bool download_and_install_webview2_verbose(void);

// Устанавливает если не установлен (0 = уже есть, 1 = успешно, -1 = ошибка)
int install_webview2_if_not_installed(void);

// С подробным выводом
int install_webview2_if_not_installed_verbose(void);

Пример на C

#include <windows.h>
#include <stdio.h>

typedef bool (*is_installed_fn)(void);
typedef int (*install_if_needed_fn)(void);

int main() {
    HMODULE dll = LoadLibrary("webview2_installer_x64.dll");
    if (!dll) return 1;
    
    auto is_installed = (is_installed_fn)GetProcAddress(dll, "is_webview2_installed");
    auto install_if_needed = (install_if_needed_fn)GetProcAddress(dll, "install_webview2_if_not_installed");
    
    if (is_installed && install_if_needed) {
        int result = install_if_needed();
        printf("Result: %d\n", result);
    }
    
    FreeLibrary(dll);
    return 0;
}

🛠️ Разработка и сборка

Требования

  • Rust (2021 edition)
  • Python 3.8+
  • Visual Studio Build Tools (Windows)
  • cargo, rustup
  • rcedit

Сборка DLL

# Собрать release версии для всех архитектур
python build_dll.py

# Собрать debug версии
python build_dll.py --debug

# Динамическая линковка (требуется VC++ Redist)
python build_dll.py --dynamic

Сборка Python пакета

# Установка зависимостей разработки
pip install -e ".[dev]"

# Сборка пакета
python -m build

# Или через devscript
devscript build_wheel

Очистка файлов сборки

devscript clean

📋 Требования к системе

  • ОС: Windows 7 / 8 / 10 / 11
  • Архитектуры: x86, x64, ARM64
  • Python: 3.8+ (для Python пакета)
  • Интернет: требуется для загрузки установщика

🔍 Как это работает

  1. Проверка установки: через реестр Windows проверяется наличие ключей WebView2
  2. Загрузка: скачивается официальный установщик от Microsoft
  3. Установка: запускается в тихом режиме (/silent /install)
  4. Очистка: временные файлы автоматически удаляются

📄 Лицензия

MIT License

🤝 Вклад в проект

PR и Issues приветствуются! Убедитесь, что изменения работают на всех целевых архитектурах.

⚠️ Известные ограничения

  • Только Windows (целевая платформа)
  • Установка синхронная — требуется подождать, пока webview2 установится

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

webview2_installer-1.0.1.tar.gz (4.9 MB view details)

Uploaded Source

Built Distribution

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

webview2_installer-1.0.1-py3-none-any.whl (5.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: webview2_installer-1.0.1.tar.gz
  • Upload date:
  • Size: 4.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for webview2_installer-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e1f6d71afe3e64b59916e33ef399e25daa1f05f312188f76dc947cbc1a2b944d
MD5 79bb2f7bc76007e9ebf6cf2cff8dd332
BLAKE2b-256 8fd5718a3ede3b71ee0bf0cbedf438e8c44802eca80ffa5dede7909c2a92c8df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for webview2_installer-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe0d505c7bbb6ab5b14b90dcef35f5f050abc4e3379198250bad0cc2a845a1fe
MD5 d97c21ea2f0ca3114f0efdf6f355e46a
BLAKE2b-256 2dd2bcb3a6901bb8e83f3e0c862047c2265563ad7137f8a299595e30f7190492

See more details on using hashes here.

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