Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding functionality to auto select the latest, stable version of pyt… #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gregkorte
Copy link

@gregkorte gregkorte commented Aug 23, 2024

…hon for installs

To test:
Create a test.sh file in any directory
Paste the requested changes into the file:

#!/bin/bash

# Define the Python download URL prefix
PYTHON_DOWNLOAD_URL_PREFIX="https://www.python.org/ftp/python"

# Fetch the list of available Python versions
VERSION_LIST=$(curl -s "$PYTHON_DOWNLOAD_URL_PREFIX/" | grep -oP '(?<=href=")[0-9]+\.[0-9]+\.[0-9]+(?=/")')

# Filter out non-stable versions (e.g., alphas, betas, release candidates)
STABLE_VERSIONS=$(echo "$VERSION_LIST" | grep -E '^[0-9]+\.[0-9]*[02468]\.[0-9]+$')

# Get the latest stable version
LATEST_STABLE_VERSION=$(echo "$STABLE_VERSIONS" | sort -V | tail -n 1)

echo $LATEST_STABLE_VERSION

Change file permissions chmod +x test.sh
Run the file from the command line ./test.sh

Expected result:
You should see the latest stable Python version number

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant