From d90dbed6d6b8475a5ecede4eb8eb52883392eaa9 Mon Sep 17 00:00:00 2001 From: Leo Date: Sat, 19 Sep 2026 13:43:43 +0400 Subject: [PATCH] docs: improve developer onboarding and contribution experience (#1954) Fix false diagnostic failures in make doctor by moving metaapi-cloud-sdk from CORE_DEPENDENCIES to OPTIONAL_DEPENDENCIES in scripts/doctor.py. Enhance scripts/bootstrap.sh to discover python3.11 when default python3 points to another version. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: triqbit <242833443+triqbit@users.noreply.github.com> --- .python-version | 2 +- scripts/bootstrap.sh | 17 ++++++++++++----- scripts/doctor.py | 13 ++++++++++++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.python-version b/.python-version index 2c073331..2419ad5b 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.11 +3.11.9 diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 2c278d6d..a4d516ed 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -4,16 +4,23 @@ set -e echo "=== MT5 AI/ML Trading Bot Bootstrapper ===" # 1. Check Python -python3 --version || { echo "Python 3 not found"; exit 1; } -if ! python3 -c 'import sys; raise SystemExit(not (sys.version_info[:2] == (3, 11)))'; then - echo "Python 3.11 is required. Found: $(python3 --version 2>&1)" +PYTHON_EXEC="python3" +if command -v python3.11 &>/dev/null; then + if python3.11 -c 'import sys; sys.exit(0 if sys.version_info[:2] == (3, 11) else 1)' 2>/dev/null; then + PYTHON_EXEC="python3.11" + fi +fi + +$PYTHON_EXEC --version || { echo "Python 3 not found"; exit 1; } +if ! $PYTHON_EXEC -c 'import sys; raise SystemExit(not (sys.version_info[:2] == (3, 11)))' 2>/dev/null; then + echo "Python 3.11 is required. Found: $($PYTHON_EXEC --version 2>&1)" exit 1 fi # 2. Setup virtual environment if not present if [ ! -d "venv" ]; then - echo "Creating virtual environment..." - python3 -m venv venv + echo "Creating virtual environment using $PYTHON_EXEC..." + $PYTHON_EXEC -m venv venv fi # 3. Create required directories diff --git a/scripts/doctor.py b/scripts/doctor.py index e9f5b89b..d515532d 100644 --- a/scripts/doctor.py +++ b/scripts/doctor.py @@ -116,7 +116,6 @@ CORE_DEPENDENCIES = { "pydantic": ("pydantic", "2.10.4"), "pydantic-settings": ("pydantic_settings", "2.7.0"), "sqlalchemy": ("sqlalchemy", "2.0.36"), - "metaapi-cloud-sdk": ("metaapi_cloud_sdk", "29.1.1"), "torch": ("torch", "2.5.1"), "fastapi": ("fastapi", "0.115.6"), "structlog": ("structlog", "24.4.0"), @@ -144,6 +143,10 @@ CORE_DEPENDENCIES = { "optuna": ("optuna", "4.9.0"), } +OPTIONAL_DEPENDENCIES = { + "metaapi-cloud-sdk": ("metaapi_cloud_sdk", "29.1.1"), +} + def check_dependencies(dependencies=None): try: @@ -195,6 +198,14 @@ def check_dependencies(dependencies=None): except ImportError: missing.append(display_name) + if dependencies is None: + for display_name, val in OPTIONAL_DEPENDENCIES.items(): + module_name = val[0] if isinstance(val, tuple) else val + try: + __import__(module_name) + except ImportError: + optional_missing.append(display_name) + if missing: remedy = "Run 'make bootstrap' to install missing dependencies." return DiagnosticCheck(