# Makefile for StabilityTester # Version: 1.0.1 # Interface: PySide6 (Qt for Python) .PHONY: help install run test clean all check-python venv prerequis clean-venv info build-windows # Variables VENV_DIR := .venv PYTHON := python3 PIP := pip REQUIREMENTS := requirements.txt # Build Windows (croise, via Wine) WINE_PREFIX := $(HOME)/.wine-stabilitytester WIN_PYTHON_VERSION := 3.13.15 WIN_PYTHON := C:\\Python313\\python.exe # PySide6 est epingle pour le build Windows : a partir de 6.10, Qt6Core.dll # depend de icuuc.dll (ICU systeme de Windows 10+) que Wine n'implemente pas, # ce qui rend l'analyse PyInstaller impossible. 6.9.3 s'en passe. WIN_PYSIDE6 := PySide6==6.9.3 # Detect OS UNAME := $(shell uname -s) # Default target help: @echo "๐ŸŒ StabilityTester - Makefile" @echo "============================" @echo "" @echo "Targets:" @echo " prerequis - ๐Ÿ“‹ Install system prerequisites" @echo " venv - ๐Ÿ Create Python virtual environment" @echo " install - ๐Ÿ“ฆ Install Python dependencies" @echo " run - ๐Ÿš€ Run the application" @echo " test - ๐Ÿงช Run basic tests" @echo " build-windows - ๐ŸชŸ Build the Windows .exe (via Wine)" @echo " clean - ๐Ÿงน Clean build artifacts" @echo " clean-venv - ๐Ÿงน Remove virtual environment" @echo " all - ๐Ÿ”„ Install prerequisites, venv, dependencies and run" @echo " info - ๐Ÿ“Š Show environment info" @echo " check-py - ๐Ÿ Check Python version" @echo "" # Check Python version check-python: @$(PYTHON) --version # Install system prerequisites prerequis: @echo "๐Ÿ“‹ Installing system prerequisites..." @echo "Detected OS: $(UNAME)" ifeq ($(UNAME),Linux) @echo "๐Ÿง Linux detected - Installing required packages..." @if [ -f /etc/os-release ]; then \ . /etc/os-release && \ if [ "$$ID" = "ubuntu" ] || [ "$$ID" = "debian" ] || [ "$$ID_LIKE" = "debian" ]; then \ sudo apt-get update -qq && \ sudo apt-get install -y -qq python3 python3-pip python3-venv libgl1 libxcb-xinerama0 libxkbcommon-x11-0 libxcb-cursor0 || echo "โš ๏ธ Some packages may have failed to install"; \ fi; \ fi @echo "โœ… System prerequisites installed!" else ifeq ($(UNAME),Darwin) @echo "๐ŸŽ macOS detected" @echo "โœ… macOS prerequisites are typically pre-installed!" @echo "If you have issues, install: brew install pythonqt" else @echo "๐ŸชŸ Windows detected" @echo "โœ… Windows prerequisites are typically pre-installed!" @echo "Make sure Python is in your PATH" endif # Create virtual environment venv: @echo "๐Ÿ Creating Python virtual environment..." @if [ ! -d "$(VENV_DIR)" ]; then \ $(PYTHON) -m venv $(VENV_DIR) && \ echo "โœ… Virtual environment created at $(VENV_DIR)"; \ else \ echo "โ„น๏ธ Virtual environment already exists at $(VENV_DIR)"; \ fi @echo "" @echo "To activate the virtual environment, run:" @echo " source $(VENV_DIR)/bin/activate" # Install dependencies install: @echo "๐Ÿ“ฆ Installing Python dependencies..." @if [ -d "$(VENV_DIR)" ]; then \ echo "Using virtual environment at $(VENV_DIR)"; \ $(VENV_DIR)/bin/pip install -r $(REQUIREMENTS) && \ echo "โœ… Dependencies installed in virtual environment!"; \ else \ $(PIP) install -r $(REQUIREMENTS) && \ echo "โœ… Dependencies installed globally!"; \ fi # Run the application run: @echo "๐Ÿš€ Starting StabilityTester with PySide6..." @if [ -d "$(VENV_DIR)" ]; then \ $(VENV_DIR)/bin/python main.py; \ else \ $(PYTHON) main.py; \ fi # Run basic tests test: @echo "๐Ÿงช Running basic tests..." @if [ -d "$(VENV_DIR)" ]; then \ $(VENV_DIR)/bin/python -c "from core.network_tester import NetworkTester; t = NetworkTester(); r = t.connection_test(); print(f'โœ… Connection test: {r.success}')" && \ $(VENV_DIR)/bin/python -c "from monitor.monitor import StabilityMonitor; m = StabilityMonitor(); print(f'โœ… StabilityMonitor created successfully')" && \ $(VENV_DIR)/bin/python -c "from gui.app import StabilityTesterWindow; print(f'โœ… PySide6 GUI loaded successfully')"; \ else \ $(PYTHON) -c "from core.network_tester import NetworkTester; t = NetworkTester(); r = t.connection_test(); print(f'โœ… Connection test: {r.success}')" && \ $(PYTHON) -c "from monitor.monitor import StabilityMonitor; m = StabilityMonitor(); print(f'โœ… StabilityMonitor created successfully')" && \ $(PYTHON) -c "from gui.app import StabilityTesterWindow; print(f'โœ… PySide6 GUI loaded successfully')"; \ fi @echo "๐ŸŽ‰ All basic tests passed!" # Build de l'executable Windows depuis Linux. # PyInstaller ne sait pas cross-compiler : on execute un Python Windows sous # Wine. Le prefixe est provisionne une seule fois puis reutilise. build-windows: @echo "๐ŸชŸ Building Windows executable via Wine..." @command -v wine >/dev/null 2>&1 || { echo "โŒ wine is required (apt install wine winetricks)"; exit 1; } @if [ ! -f "$(WINE_PREFIX)/drive_c/Python313/python.exe" ]; then \ echo "๐Ÿ“ฅ Provisioning Wine prefix (one-time, downloads ~1 GB)..."; \ WINEPREFIX=$(WINE_PREFIX) WINEARCH=win64 wineboot --init >/dev/null 2>&1; \ echo "๐Ÿ“ฅ Installing native UCRT (Wine's builtin lacks the C99 complex math NumPy needs)..."; \ WINEPREFIX=$(WINE_PREFIX) winetricks -q -f vcrun2022 ucrtbase2019 >/dev/null 2>&1; \ curl -sL -o /tmp/python-win.exe \ https://www.python.org/ftp/python/$(WIN_PYTHON_VERSION)/python-$(WIN_PYTHON_VERSION)-amd64.exe && \ WINEPREFIX=$(WINE_PREFIX) wine /tmp/python-win.exe /quiet InstallAllUsers=1 \ PrependPath=1 Include_test=0 TargetDir='C:\\Python313' && \ rm -f /tmp/python-win.exe; \ else \ echo "โ„น๏ธ Wine prefix already provisioned at $(WINE_PREFIX)"; \ fi @echo "๐Ÿ“ฆ Installing Windows dependencies..." @WINEPREFIX=$(WINE_PREFIX) WINEDEBUG=-all wine $(WIN_PYTHON) -m pip install --no-input \ --disable-pip-version-check -q -r $(REQUIREMENTS) "$(WIN_PYSIDE6)" pyinstaller @echo "๐Ÿ”จ Running PyInstaller..." @WINEPREFIX=$(WINE_PREFIX) wineserver -k 2>/dev/null || true @rm -f dist/StabilityTester.exe @WINEPREFIX=$(WINE_PREFIX) WINEDEBUG=-all wine $(WIN_PYTHON) -m PyInstaller \ --noconfirm --clean --distpath dist --workpath build StabilityTester.spec @WINEPREFIX=$(WINE_PREFIX) wineserver -k 2>/dev/null || true @echo "โœ… Windows executable: dist/StabilityTester.exe" @ls -lh dist/StabilityTester.exe # Clean build artifacts clean: @echo "๐Ÿงน Cleaning build artifacts..." find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true find . -name "*.pyc" -delete 2>/dev/null || true find . -name "*.pyo" -delete 2>/dev/null || true @echo "โœ… Cleanup complete!" # Remove virtual environment clean-venv: @echo "๐Ÿงน Removing virtual environment..." @if [ -d "$(VENV_DIR)" ]; then \ rm -rf $(VENV_DIR) && \ echo "โœ… Virtual environment removed!"; \ else \ echo "โ„น๏ธ No virtual environment found"; \ fi # Install everything and run all: prerequis venv install run # Show environment info info: @echo "๐Ÿ“Š StabilityTester - Environment Info" @echo "=================================" @echo "" @echo "Python version:" @$(PYTHON) --version @echo "" @echo "Pip version:" @$(PIP) --version 2>/dev/null || echo "pip not found" @echo "" @echo "Virtual environment:" @if [ -d "$(VENV_DIR)" ]; then \ ls -la $(VENV_DIR)/bin/python* 2>/dev/null | head -1 || echo "$(VENV_DIR) exists"; \ else \ echo "No virtual environment"; \ fi @echo "" @echo "Installed packages:" @if [ -d "$(VENV_DIR)" ]; then \ $(VENV_DIR)/bin/pip list 2>/dev/null | grep -E "(PySide6|requests|matplotlib|speedtest|ping3)" || echo "No packages in venv"; \ else \ $(PIP) list 2>/dev/null | grep -E "(PySide6|requests|matplotlib|speedtest|ping3)" || echo "No packages found"; \ fi