installkernel-wsl

Python versions PyPI - Version GitHub tag (with filter) License GitHub commits since latest release (by SemVer including pre-releases) CodeQL QA Tests Coverage Status Dependabot Documentation Status mypy uv pytest Ruff Downloads Stargazers pre-commit Prettier Follow @Tatsh Mastodon Follow

Script and installkernel hook to copy Linux kernel to the host system and update .wslconfig.

Commands

installkernel-wsl

Script and hook to copy Linux kernel to the host system and update .wslconfig.

Usage

installkernel-wsl [OPTIONS] COMMAND [COMMAND_ARGS]...

Options

-d, --debug

Enable debug level logging.

Arguments

COMMAND

Required argument

COMMAND_ARGS

Optional argument(s)

Usage as a hook

After installation:

mkdir -p /etc/kernel/install.d
ln -sf "$(command -v installkernel-wsl)" /etc/kernel/install.d/99-wsl-kernel.install

Library

Main script.

installkernel_wsl.utils.copy_kernel_to_win(name: str, src: str, *, fail_immediately: bool = False) Path

Copy the kernel update config file to the WSL config directory.

Parameters:
name : str

The name of the kernel file to copy to Windows.

src : str

The source path of the kernel file to copy.

fail_immediately : bool

Whether to raise a PermissionError immediately if the file cannot be copied due to permission issues, by default False. If False, a sequential suffix will be added to the filename until a non-existing filename is found.

Returns:

Destination path of the copied kernel file (possibly with a numeric suffix).

Return type:

Path

Raises:

PermissionError – If the file cannot be copied due to permission issues and fail_immediately is True.

installkernel_wsl.utils.get_automount_root() Path

Get the automount root path.

Returns:

The configured automount root, or /mnt when unset.

Return type:

Path

installkernel_wsl.utils.get_cmd_path() Path

Get the path to cmd.exe.

Returns:

Resolved path to cmd.exe under the Windows installation.

Return type:

Path

installkernel_wsl.utils.get_win_var(var_name: str) str

Get a Windows environment variable.

Returns:

The environment variable value printed by cmd.exe.

Return type:

str

Raises:

ValueError – If cmd.exe did not print a value for the variable.

installkernel_wsl.utils.get_windows_home_path() Path

Get the Windows home path.

Returns:

The Windows user profile directory as a WSL path.

Return type:

Path

installkernel_wsl.utils.get_windows_home_purewindowspath() PureWindowsPath

Get the Windows home path as a PureWindowsPath.

Returns:

The Windows user profile directory as a PureWindowsPath.

Return type:

PureWindowsPath

installkernel_wsl.utils.get_wslconfig_path() Path

Get the path to the .wslconfig file.

Returns:

Full path to .wslconfig under the Windows user profile as a WSL path.

Return type:

Path

installkernel_wsl.utils.is_wsl() bool

Check if running under WSL.

Returns:

True if the WSL interoperability file is present, False otherwise.

Return type:

bool

installkernel_wsl.utils.update_wslconfig(kernel_path_lin: PathLike[str] | str) None

Update the .wslconfig file with the new kernel path.

installkernel_wsl.utils.wslpath(path: str | PathLike[str], *, absolute: bool = False, windows: bool = False) str

Convert a Windows path to a WSL path.

Returns:

The path string printed by wslpath.

Return type:

str

Raises:

ValueError – If wslpath did not print a value for the path.

Indices and tables