Update build script to check dependencies instead of auto-installing

 SAFER BUILD PROCESS:
- Changed install_dependencies() to check_dependencies()
- No longer automatically installs PyQt6/pyinstaller
- Provides clear instructions if dependencies are missing
- User must manually install: pip install -r requirements.txt
- Added --check-deps option for dependency verification only

TECHNICAL DETAILS:
- More secure: doesn't modify user's Python environment
- Better control: user chooses when to install packages
- Clear feedback: shows which packages are missing
- Improved workflow: separates dependency management from building

USER WORKFLOW:
1. pip install -r requirements.txt (manual)
2. python3 build_usb_creator.py (checks deps then builds)
3. Executable created if all dependencies satisfied
parent 2f668ea2
......@@ -11,23 +11,34 @@ import platform
import shutil
from pathlib import Path
def install_dependencies():
"""Install required Python packages"""
print("Installing required dependencies...")
def check_dependencies():
"""Check if required Python packages are installed"""
print("Checking required dependencies...")
packages = [
"PyQt6",
"pyinstaller",
]
missing_packages = []
for package in packages:
try:
subprocess.run([sys.executable, "-m", "pip", "install", package], check=True)
print(f"✓ {package} installed")
except subprocess.CalledProcessError:
print(f"✗ Failed to install {package}")
return False
__import__(package.lower().replace('-', '_'))
print(f"✓ {package} found")
except ImportError:
print(f"✗ {package} missing")
missing_packages.append(package)
if missing_packages:
print("\nMissing dependencies found!")
print("Please install them manually:")
print(f" pip3 install {' '.join(missing_packages)}")
print("Or install all dependencies with:")
print(" pip3 install -r requirements.txt")
return False
print("✓ All dependencies satisfied")
return True
def create_spec_file():
......@@ -186,7 +197,7 @@ python3 build_usb_creator.py
### Manual Build:
```bash
# Install dependencies
pip install -r requirements.txt
pip3 install -r requirements.txt
# Build executable
pyinstaller --clean usb_creator.spec
......@@ -249,12 +260,12 @@ def main():
print("MBetter USB Creator - Build Script")
print("=" * 40)
if len(sys.argv) > 1 and sys.argv[1] == "--deps-only":
print("Installing dependencies only...")
if install_dependencies():
print("✓ Dependencies installed successfully")
if len(sys.argv) > 1 and sys.argv[1] == "--check-deps":
print("Checking dependencies only...")
if check_dependencies():
print("✓ All dependencies available")
else:
print("✗ Failed to install dependencies")
print("✗ Missing dependencies found")
return
# Create build files
......@@ -262,9 +273,9 @@ def main():
create_spec_file()
create_build_instructions()
# Install dependencies
if not install_dependencies():
print("✗ Failed to install dependencies. Aborting build.")
# Check dependencies
if not check_dependencies():
print("✗ Missing dependencies. Please install them before building.")
return
# Build executable
......@@ -279,4 +290,4 @@ def main():
print("✗ Check error messages above")
if __name__ == '__main__':
main()
\ No newline at end of file
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment