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 ...@@ -11,23 +11,34 @@ import platform
import shutil import shutil
from pathlib import Path from pathlib import Path
def install_dependencies(): def check_dependencies():
"""Install required Python packages""" """Check if required Python packages are installed"""
print("Installing required dependencies...") print("Checking required dependencies...")
packages = [ packages = [
"PyQt6", "PyQt6",
"pyinstaller", "pyinstaller",
] ]
missing_packages = []
for package in packages: for package in packages:
try: try:
subprocess.run([sys.executable, "-m", "pip", "install", package], check=True) __import__(package.lower().replace('-', '_'))
print(f"✓ {package} installed") print(f"✓ {package} found")
except subprocess.CalledProcessError: except ImportError:
print(f"✗ Failed to install {package}") print(f"✗ {package} missing")
return False 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 return True
def create_spec_file(): def create_spec_file():
...@@ -186,7 +197,7 @@ python3 build_usb_creator.py ...@@ -186,7 +197,7 @@ python3 build_usb_creator.py
### Manual Build: ### Manual Build:
```bash ```bash
# Install dependencies # Install dependencies
pip install -r requirements.txt pip3 install -r requirements.txt
# Build executable # Build executable
pyinstaller --clean usb_creator.spec pyinstaller --clean usb_creator.spec
...@@ -249,12 +260,12 @@ def main(): ...@@ -249,12 +260,12 @@ def main():
print("MBetter USB Creator - Build Script") print("MBetter USB Creator - Build Script")
print("=" * 40) print("=" * 40)
if len(sys.argv) > 1 and sys.argv[1] == "--deps-only": if len(sys.argv) > 1 and sys.argv[1] == "--check-deps":
print("Installing dependencies only...") print("Checking dependencies only...")
if install_dependencies(): if check_dependencies():
print("✓ Dependencies installed successfully") print("✓ All dependencies available")
else: else:
print("✗ Failed to install dependencies") print("✗ Missing dependencies found")
return return
# Create build files # Create build files
...@@ -262,9 +273,9 @@ def main(): ...@@ -262,9 +273,9 @@ def main():
create_spec_file() create_spec_file()
create_build_instructions() create_build_instructions()
# Install dependencies # Check dependencies
if not install_dependencies(): if not check_dependencies():
print("✗ Failed to install dependencies. Aborting build.") print("✗ Missing dependencies. Please install them before building.")
return return
# Build executable # Build executable
...@@ -279,4 +290,4 @@ def main(): ...@@ -279,4 +290,4 @@ def main():
print("✗ Check error messages above") print("✗ Check error messages above")
if __name__ == '__main__': if __name__ == '__main__':
main() main()
\ No newline at end of file
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