Optimize: Reduce dependencies to minimal set for headless RFID client
REMOVED: - aiohttp, multidict, aiosignal, frozenlist, attrs, yarl, propcache (Flask async dependencies) - flask, chart (not needed for headless device) - selenium (web automation not needed) KEPT (7 core dependencies only): - rdm6300: RFID reader library - requests: HTTP communication to server - gpiozero: GPIO/system access - urllib3, certifi, charset_normalizer, idna: requests dependencies IMPROVEMENTS: - Skip trying to install wrong-architecture wheels (aarch64) - Let pip download correct ARM32/ARM64 version for device - Much faster startup on resource-constrained Raspberry Pi - Pure Python wheels installed from local repository - Removes 11+ unnecessary packages
This commit is contained in:
@@ -59,7 +59,7 @@ def check_and_install_dependencies():
|
||||
|
||||
for package_name, wheel_file in missing_packages:
|
||||
if wheel_file is None:
|
||||
# Try to install via pip from internet or system packages
|
||||
# Try to install via pip from internet (for system packages)
|
||||
try:
|
||||
print(f"Attempting to install {package_name} via pip...")
|
||||
result = subprocess.run([
|
||||
@@ -70,10 +70,10 @@ def check_and_install_dependencies():
|
||||
if result.returncode == 0:
|
||||
print(f"✓ {package_name} installed via pip")
|
||||
else:
|
||||
print(f"✗ Could not install {package_name} via pip: {result.stderr}")
|
||||
if package_name in ['flask', 'gpiozero']:
|
||||
print(f"⚠ pip install failed, trying apt...")
|
||||
if package_name in ['gpiozero']:
|
||||
try:
|
||||
print(f"Trying to install {package_name} via apt...")
|
||||
print(f"Attempting to install {package_name} via apt...")
|
||||
result = subprocess.run([
|
||||
'sudo', 'apt', 'install', '-y', f'python3-{package_name}',
|
||||
'--no-install-recommends'
|
||||
@@ -88,9 +88,26 @@ def check_and_install_dependencies():
|
||||
except Exception as pip_e:
|
||||
print(f"✗ pip install failed: {pip_e}")
|
||||
else:
|
||||
# Try to install from wheel file
|
||||
# Try to install from wheel file (pure Python wheels like rdm6300, certifi, etc.)
|
||||
wheel_path = f"{repository_path}/{wheel_file}"
|
||||
install_package_from_wheel(wheel_path, package_name)
|
||||
# Only try wheel files that are pure Python (not architecture-specific)
|
||||
if not ('aarch64' in wheel_file or 'armv' in wheel_file):
|
||||
install_package_from_wheel(wheel_path, package_name)
|
||||
else:
|
||||
# For architecture-specific wheels, try pip to get the right arch
|
||||
print(f"Skipping wheel {package_name} (wrong architecture), trying pip...")
|
||||
try:
|
||||
result = subprocess.run([
|
||||
sys.executable, "-m", "pip", "install", package_name,
|
||||
"--break-system-packages", "--no-warn-script-location"
|
||||
], capture_output=True, text=True, timeout=120)
|
||||
|
||||
if result.returncode == 0:
|
||||
print(f"✓ {package_name} installed via pip")
|
||||
else:
|
||||
print(f"✗ Could not install {package_name}: {result.stderr}")
|
||||
except Exception as e:
|
||||
print(f"✗ Error installing {package_name}: {e}")
|
||||
|
||||
|
||||
def verify_dependencies():
|
||||
|
||||
Reference in New Issue
Block a user