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