Commit 79fdca95 authored by robbuckley's avatar robbuckley
Browse files

fix build flags to 64b-only for PyPy

parent 4c993575
......@@ -16,7 +16,7 @@ BUILD_PREFIX="${BUILD_PREFIX:-/usr/local}"
# IS_OSX is defined in common_utils.sh
if [ -n "$IS_OSX" ]; then
source $MULTIBUILD_DIR/osx_utils.sh
PLAT=$(mac_cpython_arch_for_osx_ver)
PLAT=$(macpython_arch_for_version $MB_PYTHON_VERSION)
if [[ $PLAT == intel ]]; then
ARCH_FLAGS=${ARCH_FLAGS:-"-arch i386 -arch x86_64"}
elif [[ $PLAT == x86_64 ]]; then
......
......@@ -170,23 +170,61 @@ function get_macpython_osx_ver {
fi
}
function mac_cpython_arch_for_osx_ver {
# echo arch (intel or x86_64) for CPython python.org builds targetted for
# the given minimum macOS version
function macpython_arch_for_version {
# echo arch (e.g. intel or x86_64) that a version of CPython is expected
# to be built for, given the minimum macOS version
# Parameters
# $py_osx_ver (major.minor | not defined}
# the macosx version that Python is built for, e.g.
# "10.6" or "10.9", or MB_PYTHON_OSX_VER if undefined
#
py_osx_ver=${1:-$MB_PYTHON_OSX_VER}
# $py_ver Python version, e.g. (major.minor.patch) for CPython,
# or pypy-(major.minor) for PyPy
# $py_osx_ver minimum macOS version the target Python is built for
local py_ver=$1
local py_osx_ver=${2:-$MB_PYTHON_OSX_VER}
check_var $1
if [[ $(macpython_impl_for_version $py_ver) == "cp" ]]; then
if [[ "$py_osx_ver" == "10.6" ]]; then
echo "intel"
elif [[ "$py_osx_ver" == "10.9" ]]; then
echo "x86_64"
else
echo "Unexpected python osx version: ${py_osx_ver}, supported values: 10.6 and 10.9"
echo "Unexpected CPython osx version: ${py_osx_ver}, supported values: 10.6 and 10.9"
exit 1
fi
else
echo "x86_64"
fi
}
function macpython_impl_for_version {
# echo Python implementation (cp for CPython, pp for PyPy) given a
# suitably formatted version string
# Parameters:
# $version : [implementation-]major[.minor[.patch]]
# Python implementation, e.g. "3.6" for CPython or
# "pypy-5.4" for PyPy
local version=$1
check_var $1
if [[ "$version" =~ pypy-([0-9\.]+) ]]; then
echo pp
elif [[ "$version" =~ ([0-9\.]+) ]]; then
echo cp
else
echo "config error: Issue parsing this implementation in install_python:"
echo " version=$version"
exit 1
fi
}
function strip_macpython_ver_prefix {
# strip the implementation prefix from a Python version string
# Parameters:
# $version : [implementation-]major[.minor[.patch]]
# Python implementation, e.g. "3.6" for CPython or
# "pypy-5.4" for PyPy
local version=$1
check_var $1
if [[ "$version" =~ (pypy-)?([0-9\.]+) ]]; then
echo ${BASH_REMATCH[2]}
fi
}
function install_macpython {
......@@ -199,13 +237,14 @@ function install_macpython {
# "10.6" or "10.9". Ignored for PyPy
local version=$1
local py_osx_ver=$2
if [[ "$version" =~ pypy-([0-9\.]+) ]]; then
install_mac_pypy "${BASH_REMATCH[1]}"
elif [[ "$version" =~ ([0-9\.]+) ]]; then
install_mac_cpython "${BASH_REMATCH[1]}" $py_osx_ver
local impl=$(macpython_impl_for_version $version)
local stripped_ver=$(strip_macpython_ver_prefix $version)
if [[ "$impl" == "pp" ]]; then
install_mac_pypy $stripped_ver
elif [[ "$impl" == "cp" ]]; then
install_mac_cpython $stripped_ver $py_osx_ver
else
echo "config error: Issue parsing this implementation in install_python:"
echo " version=$version"
echo "Unexpected Python impl: ${impl}"
exit 1
fi
}
......
......@@ -19,6 +19,7 @@ else
fi
if [ -n "$TEST_BUILDS" ]; then
if [ -n "$IS_OSX" ]; then
MB_PYTHON_VERSION=${MB_PYTHON_VERSION:-$PYTHON_VERSION}
source tests/test_library_builders.sh
elif [ ! -x "$(command -v docker)" ]; then
echo "Skipping build tests; no docker available"
......
......@@ -24,14 +24,21 @@
[ "$(get_py_mm)" == "${cpython_version:0:3}" ] || ingest
[ "$(get_py_mm_nodot)" == $(echo "${cpython_version:0:3}" | tr -d .) ] || ingest
# test lookup of arch from CPython macOS target build
[ "$(mac_cpython_arch_for_osx_ver 10.6)" == "intel" ] || ingest
[ "$(mac_cpython_arch_for_osx_ver 10.9)" == "x86_64" ] || ingest
# test lookup of arch from Python macos target build
[ "$(macpython_arch_for_version 2.7 10.6)" == "intel" ] || ingest
[ "$(macpython_arch_for_version 2.7 10.9)" == "x86_64" ] || ingest
[ "$(macpython_arch_for_version pypy-2.7)" == "x86_64" ] || ingest
# test lookup of arch / min macOS versions from installed python distutils tag
[ "$(get_macpython_arch macosx-10.6-intel)" == "intel" ] || ingest
[ "$(get_macpython_arch macosx-10.6-x86_64)" == "x86_64" ] || ingest
[ "$(get_macpython_osx_ver macosx-10.6-intel)" == "10.6" ] || ingest
# test utilities for extracting version and impl from Python version string
[ "$(strip_macpython_ver_prefix 3.7.2)" == "3.7.2" ] || ingest
[ "$(strip_macpython_ver_prefix pypy-5.4)" == "5.4" ] || ingest
[ "$(macpython_impl_for_version 3.7.2)" == "cp" ] || ingest
[ "$(macpython_impl_for_version pypy-5.4)" == "pp" ] || ingest
# Test pkg-config install
install_pkg_config
\ No newline at end of file
......@@ -61,17 +61,12 @@ else # not virtualenv
fi
fi
# for CPython, check macOS version and arch are as expected
# check macOS version and arch are as expected
distutils_plat=$($PYTHON_EXE -c "import distutils.util; print(distutils.util.get_platform())")
echo "Python cmd archs: $(lipo -info $(which $PYTHON_EXE))"
if [[ $requested_impl = 'cp' ]]; then
echo "CPython, checking platform..."
expected_tag="macosx-${MB_PYTHON_OSX_VER}-$(mac_cpython_arch_for_osx_ver)"
if ! [[ $distutils_plat == $expected_tag ]]; then
ingest "Wrong Python platform tag: ${distutils_plat}!=${expected_tag}"
fi
elif [[ $requested_impl = 'py' ]]; then
echo "PyPy, skipping platform check..."
expected_arch=$(macpython_arch_for_version $PYTHON_VERSION)
if [[ $requested_impl == 'cp' ]]; then
expected_tag="macosx-$MB_PYTHON_OSX_VER-$expected_arch"
else
ingest "Invalid impl: '${requested_impl}', expecting 'cp' or 'py'"
expected_tag="macosx-(10.[0-9]+)-$expected_arch"
fi
[[ $distutils_plat =~ $expected_tag ]] || ingest
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