mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-17 13:08:51 +03:00
Start of 5.X work
This commit is contained in:
48
tools/protoc_utils/check_python_packages.py
Normal file
48
tools/protoc_utils/check_python_packages.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import sys
|
||||
import pkg_resources
|
||||
import subprocess
|
||||
|
||||
def check_packages(packages):
|
||||
missing_packages = []
|
||||
for package in packages:
|
||||
try:
|
||||
pkg_resources.require(package)
|
||||
except pkg_resources.DistributionNotFound:
|
||||
missing_packages.append(package)
|
||||
return missing_packages
|
||||
|
||||
def install_packages(packages):
|
||||
for package in packages:
|
||||
try:
|
||||
print(f"Installing {package}...")
|
||||
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
||||
except subprocess.CalledProcessError:
|
||||
print(f"Failed to install {package}.")
|
||||
return False
|
||||
return True
|
||||
|
||||
required_packages = ["protobuf", "grpcio-tools"]
|
||||
missing_packages = check_packages(required_packages)
|
||||
|
||||
if missing_packages:
|
||||
print("Missing required Python packages:", ", ".join(missing_packages))
|
||||
if install_packages(missing_packages):
|
||||
missing_packages = check_packages(required_packages)
|
||||
if missing_packages:
|
||||
print("Still missing required Python packages after installation attempt:", ", ".join(missing_packages))
|
||||
sys.exit(1)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
||||
print("All required Python packages are installed.")
|
||||
|
||||
# Check for the marker file path argument
|
||||
if len(sys.argv) < 2:
|
||||
print("Error: No marker file path provided.")
|
||||
sys.exit(1)
|
||||
|
||||
marker_file_path = sys.argv[1]
|
||||
with open(marker_file_path, "w") as marker_file:
|
||||
marker_file.write("Python packages check completed successfully.")
|
||||
|
||||
sys.exit(0)
|
||||
Reference in New Issue
Block a user