Skip to content

refactor: remove runtime package installation from flash_windows - #209

Merged
Hog185 merged 4 commits into
Hogjects:devfrom
abusaeed-shuvo:fix-feature
Aug 11, 2026
Merged

refactor: remove runtime package installation from flash_windows#209
Hog185 merged 4 commits into
Hogjects:devfrom
abusaeed-shuvo:fix-feature

Conversation

@abusaeed-shuvo

Copy link
Copy Markdown
Contributor

Refactor: Remove runtime package installation from flash_windows

Target branch: dev
Labels: refactor, bug-fix


Summary

Removed all runtime package installation logic from flash_windows.py. Tools like ntfs-3g, wimtools, and exfatprogs are now declared as system dependencies and expected to be present at runtime. Missing tools now raise a clean FileNotFoundError with a human-readable install hint instead of silently attempting installs.


Changes

  • _find_ntfs_tool() — removed apt/dnf/pacman/zypper install logic, removed unused status_cb parameter, now raises FileNotFoundError if no tool is found
  • _ensure_wimlib() → renamed to _check_wimlib() — removed all install logic, now only checks for presence and raises on miss
  • Added requirements-system.txt declaring: ntfs-3g, wimtools, exfatprogs, util-linux, udev, parted
  • Removed unused contextlib import

No changes to requirements-python.txt — this file has no third-party Python dependencies.


Before & After

Before (silent install attempt):

ntfs-3g not found, attempting to install...
[runs apt-get install -y ntfs-3g]

After (clean error):

FileNotFoundError: mkfs.ntfs / mkntfs not found. Install ntfs-3g:
sudo apt install ntfs-3g  /  sudo pacman -S ntfs-3g

Known Limitations

  • The download fallback for uefi-ntfs.img is still present — this is intentional and out of scope for this PR
  • requirements-system.txt package names follow Debian/Arch conventions; names may differ on RPM-based distros (e.g. exfatprogs vs exfat-utils)

AI Disclosure

This PR description was Generated by Copilot.


Checklist

  • PR is against dev branch
  • No duplicate PRs
  • AI use disclosed
  • Known limitations stated
  • PEP8 naming followed
  • No GUI changes (no screenshots needed)

abusaeed-shuvo and others added 2 commits May 22, 2026 12:01
wimtools
exfatprogs
util-linux
udev
parted``` from `src/lufus/writing/windows/flash.py` so i don't burn my toes
@R-Larocque

Copy link
Copy Markdown
Contributor

Please ruff format your code.
Also, did you think of a way to implement some of these packages as native Python?

@abusaeed-shuvo

Copy link
Copy Markdown
Contributor Author

Please ruff format your code. Also, did you think of a way to implement some of these packages as native Python?

Some packages can be replaced with their Python alternative library, but I don't have enough experience with them to implement them reliably.
Here is a list of packages that have Python alternatives for anyone interested in implementing them (I have used LLM for researching them):

LLM used: QWEN3.5 4B

tools:

  • name: wimlib-imagex split
    purpose: "Split WIM/ESD files >4GiB for FAT32"
    python_library:
    available: true
    library: "pywimlib"
    notes: "Python bindings for wimlib"

  • name: sfdisk
    purpose: "GPT partitioning"
    python_library:
    available: true
    library: "pyparted"
    notes: "Python bindings for libparted"

  • name: partprobe
    purpose: "Notify kernel of partition changes"
    python_library:
    available: true
    library: "pyparted / pyudev"

  • name: "blockdev --getsz"
    purpose: "Get disk size in sectors"
    python_library:
    available: true
    library: "stdlib / ioctl"
    notes: "Can use os.lseek() or ioctl() directly"

  • name: udevadm settle
    purpose: "Wait for device events"
    python_library:
    available: true
    library: "pyudev"

  • name: "wipefs -a"
    purpose: "Wipe partition signatures"
    python_library:
    available: true
    library: "raw os.open()/os.write()"
    notes: "Can be implemented directly in Python"

  • name: mount / umount
    purpose: "Mount and unmount filesystems"
    python_library:
    available: false
    library: null
    notes: "No pure Python implementation; can use ctypes with mount(2)"

  • name: dd
    purpose: "Write raw image to device"
    python_library:
    available: true
    library: "stdlib"
    notes: "Can use Python open() and write()"

  • name: sync
    purpose: "Sync filesystem buffers"
    python_library:
    available: true
    library: "os.sync()"
    notes: "Available in Python standard library"

  • name: which
    purpose: "Find executables"
    python_library:
    available: true
    library: "shutil.which()"
    notes: "Available in Python standard library"

  • name: cp
    purpose: "Copy files"
    python_library:
    available: true
    library: "shutil"
    notes: "Already supported in Python"

  • name: mkdir
    purpose: "Create directories"
    python_library:
    available: true
    library: "os.makedirs"
    notes: "Already supported in Python"

  • name: mkfs.ntfs / mkntfs
    purpose: "Format NTFS"
    python_library:
    available: false
    library: null
    notes: "No reliable Python NTFS formatter"

  • name: mkfs.exfat
    purpose: "Format exFAT"
    python_library:
    available: false
    library: null
    notes: "No Python exFAT formatter"

  • name: "mkfs.vfat -F32"
    purpose: "Format FAT32"
    python_library:
    available: false
    library: null
    notes: "No Python FAT32 formatter"

@Hog185
Hog185 merged commit 9492400 into Hogjects:dev Aug 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants