#!/usr/bin/env bash
set -eo pipefail

# 1. CHECK IF APPLICABLE
if [ ! -f "requirements.txt" ] && [ ! -f "setup.py" ] && [ ! -f ".python-version" ]; then
    exit 100
fi

# 2. GET ARGS
plan_path=$2

# 3. GET CONFIGURATION
version=3.10.2
if [[ -f .python-version ]]; then
    version=$(tr <.python-version -d '[:space:] | python-')
fi

# 4. DECLARE DEPENDENCIES
cat >>"${plan_path}" <<EOL
[[provides]]
name = "python"

[[requires]]
name = "python"

[requires.metadata]
version = "${version}"
EOL
