fix: update Python installation script to require version specification

- Modified the Python installation script to remove the default version assignment and enforce version specification during installation.
- Updated usage instructions to reflect the change from a default version to requiring a user-defined version, improving clarity and preventing installation errors.
- This change enhances the robustness of the installation process by ensuring users explicitly define the Python version they wish to install.
This commit is contained in:
Marvin Zhang
2024-12-30 15:23:54 +08:00
parent 9bdb0c969f
commit 3438919068

View File

@@ -7,7 +7,7 @@ set -e
print_usage() {
echo "Usage: $0 <command> [version] [requirements]"
echo "Commands:"
echo " install <version> - Install Python version (default: 3.12)"
echo " install <version> - Install Python version (default: latest)"
echo " uninstall <version> - Uninstall Python version"
echo " switch <version> - Switch to a different Python version"
echo " list - List installed Python versions"
@@ -104,8 +104,8 @@ handle_requirements() {
}
# Main logic
command="${1:-install}"
version="${2:-3.12.8}"
command="${1:-}"
version="${2:-}"
requirements="${3:-}"
case $command in
@@ -113,6 +113,10 @@ case $command in
setup_pyenv
;;
"install")
if [ -z "$version" ]; then
echo "Please specify a version to install"
exit 1
fi
setup_pyenv
# Check if version is already installed
if pyenv versions | grep -q $version; then