Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Launch Semantic Server.command
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,53 @@ echo "🧹 Cleaning up..."
lsof -ti:8765 | xargs kill -9 2>/dev/null
sleep 1

# --- PYTHON VERSION ENFORCEMENT ---
# The following block strictly enforces the use of Python 3.13.11.
# This is a critical system requirement. No other version is permitted.
# Any deviation will cause an immediate and fatal system exit.

# Capture the exact version string of the 'python3' command.
# This executes 'python3 --version' and stores the output (e.g., "Python 3.13.11").
# We use the system python first to check, or assume venv usage.
# Since this script activates venv later, we should check the python that WILL be used.
# But 'source venv/bin/activate' changes the python context.

echo "🐍 Verifying Python Version..."

# We need to check the python version inside the venv if it exists, or the system python.
# If venv exists, we use it.
if [ -d "venv" ]; then
PYTHON_CMD="venv/bin/python3"
else
PYTHON_CMD="python3"
fi

CURRENT_PYTHON_VERSION=$($PYTHON_CMD --version 2>&1)
REQUIRED_PYTHON_VERSION="Python 3.13.11"

# Compare the current version with the required version.
if [ "$CURRENT_PYTHON_VERSION" != "$REQUIRED_PYTHON_VERSION" ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "CRITICAL ERROR: INCORRECT PYTHON VERSION DETECTED"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
echo "The system requires exactly: $REQUIRED_PYTHON_VERSION"
echo "You are currently running: $CURRENT_PYTHON_VERSION"
echo "Command used: $PYTHON_CMD"
echo ""
echo "This enforcement is hard-coded to prevent compatibility issues."
echo "Please install Python 3.13.11 and ensure it is available."
echo ""
echo "Process aborted."
echo ""
echo "Press any key to close..."
read -n 1
exit 1
fi

echo "✅ Python Version Verified: $CURRENT_PYTHON_VERSION"


# Start Python backend
echo "🐍 Starting backend..."
source venv/bin/activate && python3 main.py &
Expand Down
37 changes: 37 additions & 0 deletions launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,43 @@ fi
# Check which python we are using
which python3

# --- 2.1 PYTHON VERSION ENFORCEMENT ---
# The following block strictly enforces the use of Python 3.13.11.
# This is a critical system requirement. No other version is permitted.
# Any deviation will cause an immediate and fatal system exit.

# Capture the exact version string of the 'python3' command.
# This executes 'python3 --version' and stores the output (e.g., "Python 3.13.11").
CURRENT_PYTHON_VERSION=$(python3 --version 2>&1)

# Define the strictly required version string.
# This MUST be exactly "Python 3.13.11".
REQUIRED_PYTHON_VERSION="Python 3.13.11"

# Compare the current version with the required version.
# If the strings are not identical, the system is in an invalid state.
if [ "$CURRENT_PYTHON_VERSION" != "$REQUIRED_PYTHON_VERSION" ]; then
# Print a loud, clear error message to the console.
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "CRITICAL ERROR: INCORRECT PYTHON VERSION DETECTED"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
echo "The system requires exactly: $REQUIRED_PYTHON_VERSION"
echo "You are currently running: $CURRENT_PYTHON_VERSION"
echo ""
echo "This enforcement is hard-coded to prevent compatibility issues."
echo "Please install Python 3.13.11 and ensure it is the default 'python3'."
echo ""
echo "Process aborted."

# Exit with a non-zero status code (1) to indicate failure.
# This stops the script immediately.
exit 1
fi

# If we passed the check, log success.
echo "✅ Python Version Verified: $CURRENT_PYTHON_VERSION"

# Check for .env file
if [ ! -f ".env" ]; then
echo "Error: .env file not found. Please create one with ASSEMBLYAI_API_KEY."
Expand Down
40 changes: 40 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,46 @@
from pathlib import Path
from typing import Any, cast, List, Optional, TypedDict, Dict

# --- 0. CRITICAL SYSTEM ENFORCEMENT ---
# The following block strictly enforces the use of Python 3.13.11.
# This check is performed immediately upon module load to prevent
# any execution in an unsupported environment.

# Define the required version tuple (Major, Minor, Micro)
# STRICT REQUIREMENT: Python 3.13.11
REQUIRED_VERSION_INFO = (3, 13, 11)

# Check the current system version against the requirement.
# sys.version_info returns a named tuple (major, minor, micro, releaselevel, serial).
# We only care about major, minor, and micro for this enforcement.
if sys.version_info[:3] != REQUIRED_VERSION_INFO:
# Construct a clear error message with current and required versions.
current_ver = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
required_ver = f"{REQUIRED_VERSION_INFO[0]}.{REQUIRED_VERSION_INFO[1]}.{REQUIRED_VERSION_INFO[2]}"

error_msg = (
"\n"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
"CRITICAL RUNTIME ERROR: INCORRECT PYTHON VERSION DETECTED\n"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n"
f"The system requires exactly: Python {required_ver}\n"
f"You are currently running: Python {current_ver}\n\n"
"This enforcement is hard-coded to prevent compatibility issues.\n"
f"Please install Python {required_ver} and ensure it is the default interpreter.\n\n"
"Process aborted immediately.\n"
)

# Print to stderr to ensure visibility even if stdout is buffered or redirected.
sys.stderr.write(error_msg)

# Force an immediate exit with status code 1.
sys.exit(1)

# Log success if verify passes (will only run if sys.exit didn't happen)
# We can't use logger yet as it's not configured, so we use print/stderr.
# sys.stderr.write(f"✅ Python Runtime Verified: {sys.version.split()[0]}\n")


from dotenv import load_dotenv
load_dotenv()

Expand Down
Loading
Loading