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
|
# 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 = {
|
REQUIRED_PACKAGES = {
|
||||||
'rdm6300': 'rdm6300-0.1.1-py3-none-any.whl',
|
'rdm6300': 'rdm6300-0.1.1-py3-none-any.whl', # RFID reader library
|
||||||
'gpiozero': None, # System package
|
'requests': 'requests-2.32.3-py3-none-any.whl', # HTTP requests to server
|
||||||
'requests': 'requests-2.32.3-py3-none-any.whl',
|
'gpiozero': None, # GPIO/system interaction (apt package)
|
||||||
'aiohttp': 'aiohttp-3.11.18-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl',
|
'urllib3': 'urllib3-2.3.0-py3-none-any.whl', # Requests dependency
|
||||||
'flask': None, # Will try pip install if needed
|
'certifi': 'certifi-2025.1.31-py3-none-any.whl', # SSL certificates
|
||||||
'urllib3': 'urllib3-2.3.0-py3-none-any.whl',
|
'charset_normalizer': 'charset_normalizer-3.4.1-py3-none-any.whl', # Requests dependency
|
||||||
'certifi': 'certifi-2025.1.31-py3-none-any.whl',
|
'idna': 'idna-3.10-py3-none-any.whl' # Requests dependency
|
||||||
'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'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REPOSITORY_PATH = FILES_DIR / "reposytory"
|
REPOSITORY_PATH = FILES_DIR / "reposytory"
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ def check_and_install_dependencies():
|
|||||||
|
|
||||||
for package_name, wheel_file in missing_packages:
|
for package_name, wheel_file in missing_packages:
|
||||||
if wheel_file is None:
|
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:
|
try:
|
||||||
print(f"Attempting to install {package_name} via pip...")
|
print(f"Attempting to install {package_name} via pip...")
|
||||||
result = subprocess.run([
|
result = subprocess.run([
|
||||||
@@ -70,10 +70,10 @@ def check_and_install_dependencies():
|
|||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
print(f"✓ {package_name} installed via pip")
|
print(f"✓ {package_name} installed via pip")
|
||||||
else:
|
else:
|
||||||
print(f"✗ Could not install {package_name} via pip: {result.stderr}")
|
print(f"⚠ pip install failed, trying apt...")
|
||||||
if package_name in ['flask', 'gpiozero']:
|
if package_name in ['gpiozero']:
|
||||||
try:
|
try:
|
||||||
print(f"Trying to install {package_name} via apt...")
|
print(f"Attempting to install {package_name} via apt...")
|
||||||
result = subprocess.run([
|
result = subprocess.run([
|
||||||
'sudo', 'apt', 'install', '-y', f'python3-{package_name}',
|
'sudo', 'apt', 'install', '-y', f'python3-{package_name}',
|
||||||
'--no-install-recommends'
|
'--no-install-recommends'
|
||||||
@@ -88,9 +88,26 @@ def check_and_install_dependencies():
|
|||||||
except Exception as pip_e:
|
except Exception as pip_e:
|
||||||
print(f"✗ pip install failed: {pip_e}")
|
print(f"✗ pip install failed: {pip_e}")
|
||||||
else:
|
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}"
|
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)
|
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():
|
def verify_dependencies():
|
||||||
|
|||||||
Reference in New Issue
Block a user