Last active
January 12, 2024 01:46
-
-
Save iklobato/00024ea81085b4c996fc2bf31def7617 to your computer and use it in GitHub Desktop.
pyenv linux install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Pyenv Installer Script | |
# | |
# This script automates the installation of Pyenv and the latest Python versions | |
# on a Debian-based system or macOS. It installs necessary dependencies, sets up Pyenv, | |
# restarts the terminal, and installs the latest Python versions concurrently. | |
# | |
# Note: Ensure you have sudo privileges to install system dependencies. | |
# | |
# For more information on Pyenv, visit https://github.com/pyenv/pyenv | |
# | |
# Created by Henrique Lobato | |
# Date: Jan 11, 2024 | |
# | |
# Detect operating system | |
if [[ "$(uname)" == "Darwin" ]]; then | |
# macOS | |
echo "Detected macOS. Installing dependencies using Homebrew..." | |
brew install openssl readline sqlite3 xz zlib | |
else | |
# Debian-based systems | |
echo "Detected Debian-based system. Installing dependencies using apt-get..." | |
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \ | |
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ | |
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl | |
fi | |
# Install pyenv | |
echo "Installing pyenv..." | |
curl -fsSL https://pyenv.run | bash | |
# Restart the terminal | |
echo "Restarting the terminal..." | |
exec "$SHELL" & | |
# Define Python versions | |
latest_versions=() | |
for version in "3.8" "3.9" "3.12"; do | |
latest_versions+=($(pyenv install --list | grep -E "^\s*$version" | grep -v "[a-z]" | tail -n 1)) | |
done | |
# Install dependencies and Python versions concurrently | |
( | |
# Install dependencies in the background | |
for version in "${latest_versions[@]}"; do | |
if [ -n "$version" ]; then | |
echo "Installing Python $version..." | |
pyenv install "$version" & | |
fi | |
done | |
# Wait for background processes to finish | |
wait | |
# Display installed Python versions | |
echo "Installed Python versions:" | |
pyenv versions | |
) & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oneliner installation
bash -c "$(curl -fsSL https://gist.githubusercontent.com/henriqueblobato/00024ea81085b4c996fc2bf31def7617/raw/983964f10546fee2586e7a09157da17ecabf5d34/pyenv_install.sh)"