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:
@@ -128,24 +128,16 @@ CONFIG_CARD_ID = 12886709 # Card used for configuration
|
||||
# DEPENDENCIES
|
||||
# ============================================================================
|
||||
|
||||
# Required Python packages and their wheel files
|
||||
# Required Python packages - MINIMAL for headless RFID client
|
||||
# Flask and aiohttp dependencies removed since we're now a headless collector
|
||||
REQUIRED_PACKAGES = {
|
||||
'rdm6300': 'rdm6300-0.1.1-py3-none-any.whl',
|
||||
'gpiozero': None, # System package
|
||||
'requests': 'requests-2.32.3-py3-none-any.whl',
|
||||
'aiohttp': 'aiohttp-3.11.18-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl',
|
||||
'flask': None, # Will try pip install if needed
|
||||
'urllib3': 'urllib3-2.3.0-py3-none-any.whl',
|
||||
'certifi': 'certifi-2025.1.31-py3-none-any.whl',
|
||||
'charset_normalizer': 'charset_normalizer-3.4.1-py3-none-any.whl',
|
||||
'idna': 'idna-3.10-py3-none-any.whl',
|
||||
'multidict': 'multidict-6.4.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl',
|
||||
'aiosignal': 'aiosignal-1.3.2-py2.py3-none-any.whl',
|
||||
'frozenlist': 'frozenlist-1.6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl',
|
||||
'attrs': 'attrs-25.3.0-py3-none-any.whl',
|
||||
'yarl': 'yarl-1.20.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl',
|
||||
'aiohappyeyeballs': 'aiohappyeyeballs-2.6.1-py3-none-any.whl',
|
||||
'propcache': 'propcache-0.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl'
|
||||
'rdm6300': 'rdm6300-0.1.1-py3-none-any.whl', # RFID reader library
|
||||
'requests': 'requests-2.32.3-py3-none-any.whl', # HTTP requests to server
|
||||
'gpiozero': None, # GPIO/system interaction (apt package)
|
||||
'urllib3': 'urllib3-2.3.0-py3-none-any.whl', # Requests dependency
|
||||
'certifi': 'certifi-2025.1.31-py3-none-any.whl', # SSL certificates
|
||||
'charset_normalizer': 'charset_normalizer-3.4.1-py3-none-any.whl', # Requests dependency
|
||||
'idna': 'idna-3.10-py3-none-any.whl' # Requests dependency
|
||||
}
|
||||
|
||||
REPOSITORY_PATH = FILES_DIR / "reposytory"
|
||||
|
||||
@@ -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}"
|
||||
# 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