Commit 38056941 authored by Matthew Brett's avatar Matthew Brett Committed by GitHub
Browse files

Merge pull request #6 from HexDecimal/mac-pypy

MRG: Add PyPy support for Mac OSX builds

Add ability to specify pypy binaries to test against.
parents d1bbe0ed 8af041e2
......@@ -29,6 +29,38 @@ matrix:
env:
- PYTHON_VERSION=3.6.0
- VENV=venv
- os: osx
env:
- PYTHON_VERSION=pypy-2.6
- VENV=venv
- os: osx
env:
- PYTHON_VERSION=pypy-4.0
- VENV=venv
- os: osx
env:
- PYTHON_VERSION=pypy-5.0
- VENV=venv
- os: osx
env:
- PYTHON_VERSION=pypy-5.1
- VENV=venv
- os: osx
env:
- PYTHON_VERSION=pypy-5.3
- VENV=venv
- os: osx
env:
- PYTHON_VERSION=pypy-5.4
- VENV=venv
- os: osx
env:
- PYTHON_VERSION=pypy-5.6
- VENV=venv
- os: osx
env:
- PYTHON_VERSION=pypy-5.7
- VENV=venv
script:
- source tests/test_multibuild.sh
......@@ -253,6 +253,10 @@ To use these scripts
language: generic
env:
- MB_PYTHON_VERSION=3.6
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=pypy-5.7
before_install:
- source multibuild/common_utils.sh
......
......@@ -74,11 +74,11 @@ function untar {
if [ -z "$in_fname" ];then echo "in_fname not defined"; exit 1; fi
local extension=${in_fname##*.}
case $extension in
tar) tar xf $in_fname ;;
gz|tgz) tar zxf $in_fname ;;
bz2) tar jxf $in_fname ;;
tar) tar -xf $in_fname ;;
gz|tgz) tar -zxf $in_fname ;;
bz2) tar -jxf $in_fname ;;
zip) unzip $in_fname ;;
xz) unxz -c $in_fname | tar xf ;;
xz) unxz -c $in_fname | tar -xf ;;
*) echo Did not recognize extension $extension; exit 1 ;;
esac
}
......@@ -262,3 +262,74 @@ function fill_submodule {
mv "${repo_copy}" "$repo_dir"
(cd "$repo_dir" && git remote set-url origin $origin_url)
}
PYPY_URL=https://bitbucket.org/pypy/pypy/downloads
# As of 2017-03-25, the latest verions of PyPy.
LATEST_PP_1=1.9
LATEST_PP_2=2.6
LATEST_PP_2p0=2.0.2
LATEST_PP_2p2=2.2.1
LATEST_PP_2p3=2.3.1
LATEST_PP_2p4=2.4.0
LATEST_PP_2p5=2.5.1
LATEST_PP_2p6=2.6.1
LATEST_PP_4=4.0
LATEST_PP_4p0=4.0.1
LATEST_PP_5=5.7
LATEST_PP_5p0=5.0.1
LATEST_PP_5p1=5.1.1
LATEST_PP_5p3=5.3.1
LATEST_PP_5p4=5.4.1
LATEST_PP_5p6=5.6.0
LATEST_PP_5p7=5.7.0
function unroll_version {
# Convert major or major.minor format to major.minor.micro using the above
# values recursively
# Parameters:
# $prefix : one of LATEST_PP or LATEST_PP3
# $version : major[.minor[.patch]]
# Hence:
# LATEST_PP 5 -> 5.7.0
# LATEST 2.7 -> 2.7.11
local prefix=$1
local ver=$2
local latest=${prefix}_${ver//./p}
if [ -n "${!latest}" ]; then
echo $(unroll_version ${prefix} ${!latest})
else
echo $ver
fi
}
function fill_pypy_ver {
# Convert major or major.minor format to major.minor.micro
# Parameters:
# $version : major[.minor[.patch]]
# Hence:
# 5 -> 5.7.0
echo $(unroll_version LATEST_PP $1)
}
function get_pypy_build_prefix {
# Return the file prefix of a PyPy file
# Parameters:
# $version : pypy2 version number
local version=$1
if [[ $version =~ ([0-9]+)\.([0-9]+) ]]; then
local major=${BASH_REMATCH[1]}
local minor=${BASH_REMATCH[2]}
if (( $major > 5 || ($major == 5 && $minor >= 3) )); then
echo "pypy2-v"
else
echo "pypy-"
fi
else
echo "error: expected version number, got $1" 1>&2
exit 1
fi
}
......@@ -90,7 +90,7 @@ function fill_pyver {
elif [ $ver == "3.2" ]; then
echo $LATEST_3p2
else
echo "Can't fill version $ver"
echo "Can't fill version $ver" 1>&2
exit 1
fi
}
......@@ -121,6 +121,23 @@ function pyinst_ext_for_version {
}
function install_macpython {
# Install Python and set $PYTHON_EXE to the installed executable
# Parameters:
# $version : [implementation-]major[.minor[.patch]]
# The Python implementation to install, e.g. "3.6" or "pypy-5.4"
local version=$1
if [[ "$version" =~ pypy-([0-9\.]+) ]]; then
install_mac_pypy "${BASH_REMATCH[1]}"
elif [[ "$version" =~ ([0-9\.]+) ]]; then
install_mac_cpython "${BASH_REMATCH[1]}"
else
echo "config error: Issue parsing this implentation in install_python:"
echo " version=$version"
exit 1
fi
}
function install_mac_cpython {
# Installs Python.org Python
# Parameter $version
# Version given in major or major.minor or major.minor.micro e.g
......@@ -147,6 +164,22 @@ function install_macpython {
fi
}
function install_mac_pypy {
# Installs pypy.org PyPy
# Parameter $version
# Version given in major or major.minor or major.minor.micro e.g
# "3" or "3.4" or "3.4.1".
# sets $PYTHON_EXE variable to python executable
local py_version=$(fill_pypy_ver $1)
local py_build=$(get_pypy_build_prefix $py_version)$py_version-osx64
local py_zip=$py_build.tar.bz2
local zip_path=$DOWNLOADS_SDIR/$py_zip
mkdir -p $DOWNLOADS_SDIR
wget -nv $PYPY_URL/${py_zip} -P $DOWNLOADS_SDIR
untar $zip_path
PYTHON_EXE=$(realpath $py_build/bin/pypy)
}
function install_pip {
# Generic install pip
# Gets needed version from version implied by $PYTHON_EXE
......@@ -208,8 +241,8 @@ function set_py_vars {
function get_macpython_environment {
# Set up MacPython environment
# Parameters:
# $version :
# major.minor.micro e.g. "3.4.1"
# $version : [implementation-]major[.minor[.patch]]
# The Python implementation to install, e.g. "3.6" or "pypy-5.4"
# $venv_dir : {directory_name|not defined}
# If defined - make virtualenv in this directory, set python / pip
# commands accordingly
......
......@@ -14,7 +14,7 @@
[ "$(pyinst_ext_for_version 3)" == pkg ] || ingest
# Test utilities for getting Python version versions
[ "$(get_py_digit)" == "${PYTHON_VERSION:0:1}" ] || ingest
[ "$(get_py_mm)" == "${PYTHON_VERSION:0:3}" ] || ingest
[ "$(get_py_mm_nodot)" == $(echo "${PYTHON_VERSION:0:3}" | tr -d .) ] || \
[ "$(get_py_digit)" == "${cpython_version:0:1}" ] || ingest
[ "$(get_py_mm)" == "${cpython_version:0:3}" ] || ingest
[ "$(get_py_mm_nodot)" == $(echo "${cpython_version:0:3}" | tr -d .) ] || \
ingest
......@@ -11,16 +11,30 @@ pip install delocate
delocate-listdeps --version || ingest "Delocate not installed right"
# Python version from Python to compare against required
python_version=$($PYTHON_EXE --version 2>&1 | awk '{print $2}')
python_mm="${PYTHON_VERSION:0:1}.${PYTHON_VERSION:2:1}"
if [[ $($PYTHON_EXE --version 2>&1 | awk '{print $2}') =~ ([0-9.]*).?([0-9.]*) ]]
then
# CPython version, 2.7.x on both CPython 2.7 and PyPy 5.4
cpython_version=${BASH_REMATCH[1]}
# CPython/PyPy version
implementer_version=${BASH_REMATCH[2]:-$cpython_version}
fi
python_mm="${cpython_version:0:1}.${cpython_version:2:1}"
# Remove implementation prefix
if [[ "$PYTHON_VERSION" =~ (pypy-)?([0-9\.]+) ]]; then
requested_version=${BASH_REMATCH[2]}
else
ingest "Error parsing PYTHON_VERSION=$PYTHON_VERSION"
fi
if [ "$python_version" != $PYTHON_VERSION ]; then
ingest "Wrong macpython python version $python_version"
# simple regex match, a 2.7 pattern will match 2.7.11, but not 2
if ! [[ "$implementer_version" =~ $requested_version ]]; then
ingest "Wrong python version: ${implementer_version}!=${requested_version}"
fi
if [ -n "$VENV" ]; then # in virtualenv
# Correct pip and Python versions should be on PATH
if [ "$($PYTHON_EXE --version)" != "$(python --version)" ]; then
if [ "$($PYTHON_EXE --version 2>&1)" != "$(python --version 2>&1)" ]; then
ingest "Python versions do not match"
fi
if [ "$($PIP_CMD --version)" != "$(pip --version)" ]; then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment