From fa71d9b2b35b656d9a2bfb2eb693e42d0e668f36 Mon Sep 17 00:00:00 2001 From: Joaquin Rodriguez Date: Wed, 10 Jun 2026 21:35:33 -0400 Subject: [PATCH] Make GUI dependency optional --- README.md | 53 +++++++++++++++++++++++++++++++------- setup.cfg | 6 ++++- setup.py | 6 +++-- src/WoeUSB/gui_launcher.py | 14 ++++++++++ 4 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 src/WoeUSB/gui_launcher.py diff --git a/README.md b/README.md index 1835f2d..9954121 100644 --- a/README.md +++ b/README.md @@ -30,45 +30,78 @@ yay -S woeusb-ng ### For other distributions -### 1. Install WoeUSB-ng's Dependencies +### 1. Install WoeUSB-ng CLI dependencies #### Ubuntu ```shell -sudo apt install git p7zip-full python3-pip python3-wxgtk4.0 grub2-common grub-pc-bin parted dosfstools ntfs-3g +sudo apt install git p7zip-full python3-pip grub2-common grub-pc-bin parted dosfstools ntfs-3g ``` #### Fedora (tested on: Fedora Workstation 33) ```shell -sudo dnf install git p7zip p7zip-plugins python3-pip python3-wxpython4 +sudo dnf install git p7zip p7zip-plugins python3-pip ``` -### 2. Install WoeUSB-ng +### 2. Install WoeUSB-ng CLI ```shell sudo pip3 install WoeUSB-ng ``` +### 3. Optional: install GUI support +#### Ubuntu + +```shell +sudo apt install python3-wxgtk4.0 +sudo pip3 install 'WoeUSB-ng[gui]' +``` + +#### Fedora (tested on: Fedora Workstation 33) +```shell +sudo dnf install python3-wxpython4 +sudo pip3 install 'WoeUSB-ng[gui]' +``` + ## Installation from source code -### 1. Install WoeUSB-ng's Build Dependencies +### 1. Install WoeUSB-ng CLI build dependencies #### Ubuntu ```shell -sudo apt install git p7zip-full python3-pip python3-wxgtk4.0 grub2-common grub-pc-bin parted dosfstools ntfs-3g +sudo apt install git p7zip-full python3-pip grub2-common grub-pc-bin parted dosfstools ntfs-3g ``` #### Arch ```shell -sudo pacman -Suy p7zip python-pip python-wxpython +sudo pacman -Suy p7zip python-pip ``` #### Fedora (tested on: Fedora Workstation 33) ```shell -sudo dnf install git p7zip p7zip-plugins python3-pip python3-wxpython4 +sudo dnf install git p7zip p7zip-plugins python3-pip ``` -### 2. Install WoeUSB-ng +### 2. Install WoeUSB-ng CLI ```shell git clone https://github.com/WoeUSB/WoeUSB-ng.git cd WoeUSB-ng sudo pip3 install . ``` +### 3. Optional: install GUI support from source +#### Arch +```shell +sudo pacman -Suy python-wxpython +sudo pip3 install '.[gui]' +``` + +#### Ubuntu +```shell +sudo apt install python3-wxgtk4.0 +sudo pip3 install '.[gui]' +``` + +#### Fedora (tested on: Fedora Workstation 33) +```shell +sudo dnf install python3-wxpython4 +sudo pip3 install '.[gui]' +``` + ## Installation from source code locally or in virtual environment ```shell git clone https://github.com/WoeUSB/WoeUSB-ng.git @@ -89,5 +122,7 @@ sudo rm /usr/share/icons/WoeUSB-ng/icon.ico \ sudo rmdir /usr/share/icons/WoeUSB-ng/ ``` +If `woeusbgui` is run without GUI dependencies installed, it will print a short message telling you to install `WoeUSB-ng[gui]`. + ## License WoeUSB-ng is distributed under the [GPL license](https://github.com/WoeUSB/WoeUSB-ng/blob/master/COPYING). diff --git a/setup.cfg b/setup.cfg index a50e120..56e8cba 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,11 +32,15 @@ packages = find: python_requires = >=3.6 include_package_data = True +[options.extras_require] +gui = + wxPython + [options.packages.find] where = src [options.entry_points] gui_scripts = - woeusbgui = WoeUSB.gui:run + woeusbgui = WoeUSB.gui_launcher:run console_scripts = woeusb = WoeUSB.core:run diff --git a/setup.py b/setup.py index e55054f..37e275d 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,8 @@ ], install_requires=[ 'termcolor', - 'wxPython', - ] + ], + extras_require={ + 'gui': ['wxPython'], + }, ) diff --git a/src/WoeUSB/gui_launcher.py b/src/WoeUSB/gui_launcher.py new file mode 100644 index 0000000..95bfac6 --- /dev/null +++ b/src/WoeUSB/gui_launcher.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + + +def run(): + try: + import WoeUSB.gui + except ImportError as error: + if error.name == 'wx': + print('WoeUSB-ng GUI dependencies are not installed.') + print("Install them with: pip install 'WoeUSB-ng[gui]'") + raise SystemExit(1) + raise + + WoeUSB.gui.run()