Last active
October 11, 2023 21:38
-
-
Save stuaxo/5d4c0363317a875617271a6d424abbba to your computer and use it in GitHub Desktop.
Download pypy builds and install to virtualenvs in ~/.virtualenvs
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 | |
set -e | |
# Download PyPy nightly builds and create a virtualenvs in ~./.virtualenvs | |
# Branch names, space seperated. | |
BRANCHES=(py3.10) | |
PLATFORM=linux64 | |
VARIANT=pypy-c-jit | |
BUILD=${VARIANT}-latest-${PLATFORM} | |
BUILD_ARTIFACT=${BUILD}.tar.bz2 | |
bold=$(tput bold) | |
normal=$(tput sgr0) | |
optionally_download() | |
{ | |
# Download artifact unless already cached. | |
local BUILD_URL=$1 | |
local BUILD_ARTIFACT=$2 | |
if [ -f "${BUILD_ARTIFACT}" ]; then | |
# Curls -z "Resume" trumps -I "If-Modified", so delete any previous file manually: | |
local LAST_MODIFIED=$(date +%s --date="`curl -sI ${BUILD_URL} | grep 'Last-Modified' | cut -c16-`") | |
local LAST_DOWNLOADED=$(stat -c %Y ${BUILD_ARTIFACT}) | |
if [ $LAST_MODIFIED -gt $LAST_DOWNLOADED ]; then | |
rm ${BUILD_ARTIFACT} | /bin/true | |
fi | |
fi | |
local CURL_ARGS="-#LOC - ${BUILD_URL}" | |
if [ -f "${BUILD_ARTIFACT}" ]; then | |
CURL_ARGS="-z ${BUILD_ARTIFACT} ${CURL_ARGS}" | |
fi | |
curl ${CURL_ARGS} | |
} | |
function download_builds() | |
{ | |
for BRANCH in "${BRANCHES[@]}" | |
do | |
local DEST_DIR=~/pypy-nightly/${BRANCH} | |
local BUILD_URL=http://buildbot.pypy.org/nightly/${BRANCH}/${BUILD_ARTIFACT} | |
mkdir -p ${DEST_DIR} | |
cd ${DEST_DIR} | |
optionally_download ${BUILD_URL} ${BUILD_ARTIFACT} | |
done | |
} | |
function create_environments() | |
{ | |
for BRANCH in "${BRANCHES[@]}" | |
do | |
local DEST_DIR=~/pypy-nightly/${BRANCH} | |
local VENV=~/.virtualenvs/pypy-nightly-${BRANCH} | |
local VENV_BIN=${VENV}/bin/python | |
cd ${DEST_DIR} | |
printf "${bold}%s${normal}" "${BRANCH} ⌛" | |
tar -jxpf ${BUILD_ARTIFACT} | |
local BUILD_ID=$(tar -tf ${BUILD_ARTIFACT} | head -1) | |
ln ${BUILD_ID} ${BUILD} -sf | |
ln ${BUILD_ID} current -sf | |
set -- ${DEST_DIR}/${BUILD}/bin/pypy* | |
local PYPY_BIN=$1 | |
printf "\b%-30s" "${PYPY_BIN/#$HOME/\~} ⌛" | |
/usr/bin/virtualenv ${VENV} -p ${PYPY_BIN} -q --clear | true | |
${VENV_BIN} -m pip install setuptools -U -q 2>&1 | true | |
printf "\b\b-> %s\n" "${VENV_BIN/#$HOME/\~}" | |
done | |
} | |
download_builds | |
create_environments |
Manually check last modified time.
Don't die on first run
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Support separate versions of pypy.